![](/img/trans.png)
[英]Flot: Order the stacking of the bars throughout screen with multiple stacked bar charts
[英]Flot: Consistent label colors throughout screen with multiple stacked bar charts
这是我的JSFIDDLE
如果在另一张图表中找到相同的标签,并且在所有图表中的堆栈栏中可能具有相同的顺序,则我需要动态标签具有相同的颜色。
例如,如果您查看紫色,则它上面有3个标签:084、080、00。紫色时只能是084/080/00。 这些应该反映屏幕中的所有图表。
$.plot($("#placeholder"), chartData, chartOptions);
您可以通过遍历chartData
数组来构建标签和使用过的颜色的列表,有关工作示例,请参见此小提琴 :
var colors = {
_count: 1
};
function distributeColors(data) {
for (var i = 0; i < data.length; i++) {
var label = data[i].label;
if (!colors[label]) {
colors[label] = colors._count++;
}
data[i].color = colors[label];
}
}
distributeColors(chartData);
distributeColors(chartData2);
distributeColors(chartData3);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.