Flot: Order the stacking of the bars throughout sc

2019-08-14 12:29发布

问题:

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]
    ]
}