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

Dynamically building our chart when the page loads


We start thinking about the bar chart we made that showed various product categories and a trend line for a chosen category. We send off another e-mail to IT to see whether they can compile the data into a JSON feed. A few minutes later, we get a reply stating that Roshan has asked for the same thing. They are still trying to get everything working, but in the interim, they created a mock JSON feed. They also sent along the URL.

We load the JSON feed in our browser. They moved all the category data into an object called categories. They also created an object called labels to hold the ticks for our chart:

{
  "categories": {
    "TVs": [378583.39, 346552.99, 368164.98, 371856.60, 366457.82, 327396.58],
    "Computers": [563621.35, 540214.96, 589978.66, 637114.31, 621279.49, 599837.31],
    "DVDs/Blu-ray": [546643.33, 517902.14, 482774.32, 455892.62, 438679.00, 406907.18],
    "Music CDs": [398583.39, 386552.99, 372738.46, 359209.91, 336457...