gpt4 book ai didi

javascript - Highcharts - 灰色图例中的唯一标题

转载 作者:行者123 更新时间:2023-11-30 07:51:25 25 4
gpt4 key购买 nike

是否可以将 highcharts 图例中隐藏系列的标题(而不是颜色标记)变灰?图片值(value) 1000 字。

Default behavior What I want

最佳答案

作为替代方案,包装 Legend.colorizeItem 后处理图例项 legendLinelegendSymbol 以“撤消”设置隐藏颜色:

(function (H) {
H.wrap(H.Legend.prototype, 'colorizeItem', function (proceed, item, visible) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
if(item.legendLine) {
item.legendLine.attr({ stroke: item.color });
}
if(item.legendSymbol) {
if ((item.options && item.options.marker) && item.legendSymbol.isMarker)
item.legendSymbol.attr(item.pointAttribs());
else
item.legendSymbol.attr({ fill: item.color });
}
});
}(Highcharts));

item.LegendSymbol 的详细代码是为了保留任何可能设置的标记选项。它模仿 colorizeItem 的默认行为,而不考虑 visible 的真实性。

参见 this JSFiddle demonstration它在使用中。

关于javascript - Highcharts - 灰色图例中的唯一标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52375729/

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