O'Reilly logo

Learning jqPlot by Scott Gottreu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Passing in both x and y values

The next option to pass in data to the chart is to use a two-dimensional array. Our inner array contains individual arrays, which in turn contain the value for x axis followed by the value for y axis. When we include both x and y values, our data points may not increment at a constant interval, as was the case in our previous chart:

   <script>
   $(document).ready(function(){
     var secondPlot = $.jqplot ('secondChart', [[[5,4],[10,7],[15,6],[20,9]]]);
   });
   </script>
   <div id="secondChart" style="width:400px;"></div>

We load this new chart in our web browser, and the results are as shown in the following figure:

Passing in both x and y values

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required