Flot 堆叠条形图,总值不相加

Flot stacked bar graph, total values not adding up

我的图表中有多个列的总数不相加。我不确定为什么。这些是 x 轴标签为 1-3 和 8-10 以及 >500 的列。

https://jsfiddle.net/shorif2000/xtu7fvm2/6/

var datasets = [{"label":"Andrew Jelley","data":[[0,7],[1,22],[7,41],[4,22],[8,58],[5,74],[2,25],[6,69],[3,19],[9,17]]},{"label":"Charles Bugge","data":[[0,4],[1,6],[7,3],[4,3],[8,6],[5,2],[2,5],[6,2],[9,4],[3,0]]},{"label":"Eduardo Augusto","data":[[0,25],[1,58],[7,35],[4,145],[8,22],[5,137],[2,54],[6,69],[3,33],[9,3]]},{"label":"Frederic Sundin","data":[[0,0],[7,11],[4,9],[8,19],[5,1],[2,1],[6,8],[3,1],[9,77],[1,0]]},{"label":"James Hope","data":[[0,4],[1,21],[7,170],[4,147],[8,151],[5,94],[2,52],[6,127],[3,22],[9,16]]},{"label":"Ker Anderson","data":[[0,3],[1,1],[7,62],[4,11],[8,93],[5,43],[2,8],[6,36],[3,3],[9,29]]},{"label":"Lee Bradbury","data":[[0,3],[1,5],[7,13],[4,33],[8,12],[5,11],[2,2],[6,14],[9,7],[3,0]]},{"label":"Leonor Barros","data":[[0,55],[1,81],[7,124],[4,187],[8,56],[5,148],[2,83],[6,180],[3,39],[9,1]]},{"label":"Malcolm King","data":[[0,9],[1,17],[7,68],[4,54],[8,50],[5,63],[2,37],[6,42],[3,13],[9,49]]},{"label":"Tom Hearn","data":[[0,0],[7,9],[4,9],[8,29],[5,14],[2,5],[6,14],[9,14],[1,0],[3,0]]}];

var options = {"series":{"stack":0,"lines":{"show":false,"fill":true,"steps":false},"bars":{"show":true,"fill":1,"align":"center","barWidth":0.5,"lineWidth":0,"numbers":{}}},"xaxis":{"ticks":[[0,"0"],[1,"1-3"],[2,"4-7"],[3,"8-10"],[4,"11-24"],[5,"25-49"],[6,"50-99"],[7,"100-199"],[8,"200-500"],[9,">500"]]},"yaxis":{"min":0,"tickDecimals":0,"minTickSize":10},"grid":{"clickable":true,"hoverable":true},"legend":{"noColumns":6,"container":{"0":{},"length":1,"context":{"location":{"hash":"","search":"","pathname":"/ranops/command-centre/graphs.php","port":"","hostname":"10.97.18.39","host":"10.97.18.39","protocol":"http:","origin":"http://10.97.18.39","href":"http://10.97.18.39/ranops/command-centre/graphs.php","ancestorOrigins":{}},"jQuery111308949944251196493":1},"selector":"#manager_accountability_ageing_profile-legend"}}};
var plotArr = {};

您的函数 getTotalForIndex(...) 通过对数据系列中一个索引的值求和来工作,但是您的数据系列的顺序不同,因此将对不同数据系列的值求和。

在对所有数据系列进行排序后(导致具有相同索引的相同 x 值),总计算有效(请参阅此更新 fiddle)。