2017-02-22 98 views
1

我的图表中有多个列总数不相加。我不知道为什么。这些是x轴标签1-3和8-10和> 500的列。Flot堆积条形图,总计值不会累加

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 = {}; 

回答

1

你的功能getTotalForIndex(...)作品在dataseries一个指数求和值,但您的数据系列是没有顺序一样,所以从不同的数据序列值相加。

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

+0

这是否意味着数据集中的数据需要按顺序排列? – shorif2000

+1

是(或者功能可以改变,但这可能更有效)。 – Raidri