Flot: Order the stacking of the bars throughout screen with multiple stacked bar charts

五迷三道 提交于 2019-12-11 10:24:01

问题


Se the JSFIDDLE

Q: I need to order the stacked bars so it'll be consistent throughout a screen with multiple stacked bar charts.
e.g if one bar has stacked labels starting with the top to bottom 087, 084, 080, 01-02, 00 then the position should be the same in all the other charts

I've tried:

chartData.sort(function(a, b){ 
    return a.label.localeCompare(b.label);
});

But it does not seem to work for stacked labels in one bar.


回答1:


There is a problem with the stacking when one data series in the chart has a gap at a specific x value. For example the middle bar (at x = 2) in chart 2:

{
    label: "084",
    data: [
        [0, 3],
        [1, 12],
        [2, 0], // this was missing, after adding it, the stacking works
        [3, 53],
        [4, 13]
    ]
}


来源:https://stackoverflow.com/questions/34136537/flot-order-the-stacking-of-the-bars-throughout-screen-with-multiple-stacked-bar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!