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

Adding trend lines to selected product categories


We can tell from the chart we just created that TVs and computers sell better than DVDs and CDs. However, with so many bars and so little perceived movement in the data between quarters, this chart doesn't tell us much more. This leads us to think about how we can make the chart more interactive. We conclude that adding a trend line to one data series will help us see whether revenue is trending up or down for a given category.

We don't want to create separate charts for each product category; so we will just add a drop-down menu with each product category. When the dropdown changes, it will submit the form and reload the page. We'll add functions to determine which drop-down item is selected, and then create a trend line for the corresponding data series. We decide to start with our query string parsing function:

  1. We open functions.js and create getQueryStringVar that accepts the parameter name. This is the name of the value from our query...