Book Image

Learning jqPlot

By : Scott Gottreu
Book Image

Learning jqPlot

By: Scott Gottreu

Overview of this book

Table of Contents (19 chapters)
Learning jqPlot
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Canvas versus CSS


jqPlot uses a combination of HTML styled by CSS and canvas elements added to the HTML. Canvas elements are created using JavaScript and jqPlot simplifies the creation of these canvas elements. When it creates a plot, it creates several different canvas elements. A separate canvas element is created for each series along with an element for the grid. If our lines or bars have shadows, there is an element for each shadow. Also, if we use the canvas renderers for our ticks or labels, those are created as canvas elements.

In the past, we modified the default jqPlot CSS styles for our legend, tooltips, and ticks. This is thanks to jqPlot creating divs or tables that we can alter using CSS styling. However, with canvas elements, the only thing we can change with CSS is the positioning of the entire canvas or change the display status. Our shadows, lines, bars, and rotated ticks are drawn on the canvas using JavaScript and, just like a painting, each piece is now part of the whole...