Flot 0.8.2 Line Chart - Color Bug

五迷三道 提交于 2019-12-22 10:44:20

问题


I was working with Flot line charts and setting their colors. I found an odd bug. After the first 3 colors, the plot uses the last color for all of the other lines. This is not the correct behavior.

What makes this even more interesting is that the legend displays the correct colors. Is this a known bug?

var dataSet = [
        {label: "d1", data: demand},
        {label: "d2", data: demand2},
        {label: "d3", data: demand3},
        {label: "d4", data: demand4},
        {label: "d5", data: demand5},
        {label: "d6", data: demand6}
    ]

$.plot(placeholder2, dataSet, {
    series: { 

    },
    legend: {
        noColumns: 0,
        position: "nw"
    },
    colors:["#2980B9","#D35400","#F39C12","#7F8CFF","#C0392B","#7F8C8D"]
});

Just to make sure that I wasn't going crazy, and to confirm, I tried the code again, but removed the colors specification. You'll see that even with Flot's default colors, the last color "sticks".


回答1:


Looks like the bug was a result of how I had the code setup. When I removed the series:{} code, it seems to work correctly.

The bug may be my fault, but that kind of repetitive behavior might need to be looked into.

$.plot(placeholder2, dataSet, {
    legend: {
        noColumns: 0,
        position: "nw"
    },
    colors:["#2980B9","#D35400","#F39C12","#7F8CFF","#C0392B","#7F8C8D"]
});


来源:https://stackoverflow.com/questions/17861227/flot-0-8-2-line-chart-color-bug

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