gpt4 book ai didi

JQuery Flotcharts 折线图 - 突出显示特定系列

转载 作者:行者123 更新时间:2023-12-01 07:57:35 25 4
gpt4 key购买 nike

是否可以在 jQuery Flotchart 上突出显示特定行(不是点,而是整个系列)?如果没有直接的可能性,也许有人有自己的片段?

将不胜感激。

编辑1:在“突出显示”下,我的意思是至少 - 改变线条的粗细。

最佳答案

这是我在最近的项目中的做法。这将使未单击的线条“变暗”(将不透明度设置为 0.1)。单击任何内容将使所有系列恢复到 1.0 不透明度:

$("#container").bind("plotclick", function (event, pos, item) {
var re = re = /\(([0-9]+,[0-9]+,[0-9]+)/;
var opacity = 1;
var seriesIdx = -1;
// note which item is clicked on
if (item) {
seriesIdx = item.seriesIndex;
opacity = 0.1;
}
// loop all the series and adjust the opacity
var modSeries =
$.map(somePlot.getData(),function(series,idx){
if (idx == seriesIdx){
series.color = 'rgba(' + re.exec(series.color )[1] + ',' + 1 + ')';
} else {
series.color = 'rgba(' + re.exec(series.color )[1] + ',' + opacity + ')';
}
return series;
});
// reload the series and redraw
somePlot.setData(modSeries);
somePlot.draw();
});

这会产生( fiddle here ):

enter image description here

如果需要的话,这应该很容易扩展到lineWidth

关于JQuery Flotcharts 折线图 - 突出显示特定系列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22964255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com