Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
HTML5 Graphing and Data Visualization Cookbook

You're reading from   HTML5 Graphing and Data Visualization Cookbook Get a complete grounding in the exciting visual world of Canvas and HTML5 using this recipe-packed cookbook. Learn to create charts and graphs, draw complex shapes, add interactivity, work with Google maps, and much more.

Arrow left icon
Product type Paperback
Published in Nov 2012
Publisher Packt
ISBN-13 9781849693707
Length 344 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ben Fhala Ben Fhala
Author Profile Icon Ben Fhala
Ben Fhala
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

HTML5 Graphing and Data Visualization Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Drawing Shapes in Canvas 2. Advanced Drawing in Canvas FREE CHAPTER 3. Creating Cartesian-based Graphs 4. Let's Curve Things Up 5. Getting Out of the Box 6. Bringing Static Things to Life 7. Depending on the Open Source Sphere 8. Playing with Google Charts 9. Using Google Maps 10. Maps in Action Index

Integrating images into our art


Lucky for us, we don't need to start from scratch always and we can leave the more complex art for external images. Let's figure out how we can integrate images into our canvas.

Getting ready

We've been in a flag theme in this chapter and getting another flag under our belt sounds real good to me right now. So let's turn our heads to Haiti and get their flag up and running. To create this flag, we need to have the image of the symbol that is placed in the center of the flag.

In the source files, you will find an image of the center graphic (at img/haiti.png). By the way, when integrating art into canvas it's always best to avoid resizing the image whenever possible via code to preserve the image quality.

How to do it...

We will prepare the background to match the flag and then put the entire image above it in the center of the canvas/flag:

  1. Follow the basic steps that we need to access the canvas. Set the width, height, and the actual context:

    var canvas = document...
You have been reading a chapter from
HTML5 Graphing and Data Visualization Cookbook
Published in: Nov 2012
Publisher: Packt
ISBN-13: 9781849693707
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image