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

Setting negative colors on a bar chart


Just as there is a default array of colors for data series in jqPlot, there is a separate array of colors used for negative values. We want the color of the negative bars in our waterfall chart to match our color scheme. We also want to modify the layout of the chart. We open our previous waterfall chart, 1168_08_03.html, as a new file and begin making the following modifications:

  1. We add in themes.js and create a version of the dataPull function to pass each JSON object to our data array. We also connect the data to our remote JSON feed as follows:

    <script src="../js/themes.js"></script>
    <script>
    $(document).ready(function(){
      function dataPull(rd,options) {
        return [[rd.revenue, 
          rd.operating_expenses, 
          rd.fixed_costs, 
          rd.returns]];
      }
    
      var waterFall = $.jqplot ('waterFall', 'data/revenue_expenses.json',
      {
  2. We set backgroundColor for our grid and set the options to pull our remote data. We also set seriesColors...