gpt4 book ai didi

dygraphs - 禁用两个系列的图例

转载 作者:行者123 更新时间:2023-12-03 23:57:27 26 4
gpt4 key购买 nike

我用图表创建了网站,以生成我使用 dygraphs 库的图表。图表显示三个系列的数据(测量值和公差)

enter image description here

如何禁用公差的图例?在 dygraphs 中是否可以禁用一个或多个系列的图例?

最佳答案

是的。如果您使用的是 dygraphs 2.0 或更高版本,您可以使用 legendFormatter 来做到这一点。 .您可以使用 legendFormatter 将图例的格式自定义为您喜欢的内容。 .但如果您只想隐藏两个系列,最简单的方法是从 series 中删除您的 Min 和 Max 系列。数组并将其交回默认格式化程序:

g = new Dygraph(
document.getElementById("graph"),
"X,Y,min,max\n" +
"1,6,3,12\n" +
"2,3,3,12\n" +
"3,4,3,12\n" +
"4,6,3,12\n" +
"5,8,3,12\n" +
"6,10,3,12\n" +
"7,12,3,12\n" +
"8,10,3,12\n",
{
legend: 'always',
series: {
min: { color: 'red' },
max: { color: 'red' },
},
legendFormatter: function(data) {
data.series = [data.series[0]]; // pick whichever series you want to keep
return Dygraph.Plugins.Legend.defaultFormatter.call(this, data);
}
});

fiddle .

关于dygraphs - 禁用两个系列的图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41946680/

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