簡體   English   中英

浮點圖:整個屏幕上一致的標簽顏色以及多個堆疊的條形圖

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM