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

Changing the background color of our chart


We start with the line chart showing profit and revenue because it is the simplest. We open our previous chart, 1168_01_06.html, and save it as a new file. We now have a remote data source with the revenue and profit numbers. We check the URL and find an object for both revenue and profit. Each object contains an array of arrays with the date as the x value and the dollar amount as the y value, as shown in the following code snippet:

{
  "Revenue": [
    ["2011-11-20", 800538], 
   ...
  ],
  "Profit": [
    ["2011-11-20", 192049.56], 
     ...
  ]
}
  1. We start by adding the functions.js script so that we can use remoteDataCallback to pull the revenue and profit numbers. We create our dataPull function and return the revenue and profit arrays wrapped in another array as follows:

    <script src="../js/jqplot.dateAxisRenderer.min.js"></script>
    <script src="../js/functions.js"></script>
    <script>
    $(document).ready(function(){
    ...