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

Reaping the benefits of the DRY code

We have one more chart to create for the VP's dashboard in the form of a bar chart showing product returns. We were able to get the data for each return category for the last 12 months in a JSON feed. We can reuse defaultBarObj and color_theme, which will speed up the building of our chart as follows:

  1. We open the chart we created a few weeks ago, 1168_03_05.html. Since all of these charts are going to be combined into one page, we need to create separate variables for our series objects and our functions to format the remote data as follows:
    $(document).ready(function(){
      var returnsSeriesObj = [];
      var returnsDataPull = function(remoteData,options) {
        return [remoteData];
      };
  2. We pass in our new series object, CategoryAxisRenderer ...

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