在flot堆栈图表中保持相同的顺序

时间:2014-06-09 10:10:02

标签: jquery flot

我遇到了这个我无法解决的问题。我想创建一个Flot堆栈图表。图表是由不遵守颜色顺序创建的,如下图所示:

enter image description here

如果你注意到在2010-20112011-2012中,蓝色必须是第一个。 这里用于获取此代码的代码:

      dataset = [
            {label: "Staff", data: staffRep, color: "#0077FF"},
            {label: "Post-doc", data: postdocRep, color: "#7D0096"},
            {label: "Student", data: studentRep, color: "#DE000F"}
        ];
        var bar_options = {
            series: {
                stack: true,
                bars: {
                    barWidth: 0.2,
                    lineWidth: 0,
                    show: true
                }
            },
            bars: {
                align: "center"
            },
            xaxis: {
                tickLength: 0,
                ticks: ticks,
                axisLabel: 'Reporting period',
                axisLabelUseCanvas: true,
                axisLabelFontSizePixels: 13,
                axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
                axisLabelPadding: 15
            },
            yaxis: {
                //max: max + j - j/2, // to avoid interference between bars and legend
                axisLabel: 'Personnel',
                axisLabelUseCanvas: true,
                axisLabelFontSizePixels: 13,
                axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
                axisLabelPadding: 5
            },
            grid: {
                hoverable: true,
                borderWidth: 0
            },
            legend: {
                backgroundColor: "#EEE",
                labelBoxBorderColor: "none"
            },
            colors:["#004078","#207800", "#613C00"]
        };
        $.plot($("#barchart"), dataset, bar_options);

0 个答案:

没有答案