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

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, ...

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