Search code examples
javascriptjquerygraphjqplot

Show group chart in jqplot


How to show the sum of bars of a tick in jqplot. I want to show the values of each month as sum in top of that bar in line as shown to below image.

enter image description here

Starting fiddler http://jsfiddle.net/bywfc5xx/1/

`var s1 = [200, 600, 700, 1000];
var s2 = [460, 210, 690, 820];
var s3 = [260, 440, 320, 200];
// Can specify a custom tick Array.
// Ticks should match up one for each y value (category) in the series.
var ticks = ['May', 'June', 'July', 'August'];`

Any help please.


Solution

  • I don't understand what are u trying to do, to have the total there use:

    var total = [s1[0] + s2[0] + s3[0], s1[1] + s2[1] + s3[1], s1[2] + s2[2] + s3[2], s1[3] + s2[3] + s3[3]];
    
    var plot1 = $.jqplot('chart1', [s1, s2, s3, total], {..
    

    The implementation: http://jsfiddle.net/e4zasp6L/

    Ok, got it,here is the updated answer: http://jsfiddle.net/282tkr12/

    series:[
            {
                  label:'Total',
                  color: 'blue' ,
                  renderer: $.jqplot.BarRenderer,
                  rendererOptions: { 
                      barWidth:80,
                      shadowAlpha: 0,
                      barPadding: -86,
                  }
                },
                {label:'Hotel'},
                {label:'Event Registration'},
                {label:'Airfare'}                
            ]