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

Adding a fill between two lines


We talk through Calvin's comments. Adding in expenses won't be too much of an issue. We could simply add the expense line to one of our existing reports but that will likely not be what they want. Visually, the gap on our chart between profit and revenue should be the total amount of expenses. You mention that we could fill in the gap between the two lines. We decide to give this a try:

  1. We leave the plugins and the data arrays alone. We pass an empty array into our data array as a placeholder for our expenses. Next, we update our title. After this, we add a new series object and label it Expenses:

    ...
        var rev_profit = $.jqplot ('revPrfChart', [revenue, profit, []],
        {
          title:'Monthly Revenue & Profit with Highlighted Expenses',
          series:[ { label: 'Revenue' }, { label: 'Profit' }, { label: 'Expenses' } ],
          legend: { show: true, placement: 'outsideGrid' },
  2. To fill in the gap between the two lines, we use the fillBetween option. The only...