show percentages and Numbers both in a Stack Flot Chart -


i try create bar chart percentage numbers on each bar number. following code, want percentage shown in bar numbers, count of each item in tool tip (vise versa) . i've tried stackedpercent didn't work.

for example these percentage values data:

        var dc20 = [[37, 0], [0, 1], [16, 2], [34, 3]];               var dc21 = [[58, 0], [0, 1], [80, 2], [62, 3]];              var dc22 = [[0, 0], [0, 1], [0, 2], [0, 3]];             var dc23 = [[5, 0], [100, 1], [4, 2], [4, 3]];              var dc24 = [[0, 0], [0, 1], [0, 2], [0, 3]];       

and these values count of records

        var dc20 = [[16, 0], [0, 1], [5, 2], [11, 3]];                 var dc21 = [[25, 0], [0, 1], [25, 2], [20, 3]];                var dc22 = [[0, 0], [0, 1], [0, 2], [0, 3]];                 var dc23 = [[2, 0], [1, 1], [1, 2], [1, 3]];                var dc24 = [[0, 0], [0, 1], [0, 2], [0, 3]];        

update fiddle link that.

the simplest solution add counts seperate array:

var counts = [     [16, 0, 5, 11],     [25, 0, 25, 20],     [0, 0, 0, 0],     [2, 1, 1, 1],     [0, 0, 0, 0] ]; 

and use in tooltipopts:

    content: function (label, xval, yval, flotitem) {         return '%' + xval + 'which has ' + counts[flotitem.seriesindex][flotitem.dataindex] + ' records ';     }, 

see updated fiddle.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -