gpt4 book ai didi

javascript - dygraphs 中超过 2 个 y 轴

转载 作者:行者123 更新时间:2023-11-29 21:55:30 24 4
gpt4 key购买 nike

查看文档,我无法确定 Dygraphs 是否可以在图形输出上支持超过 2 个 y 轴?我需要绘制许多具有许多不同轴范围的曲线。

最佳答案

这似乎是可能的。 This example似乎是通过使用 axes 和一些其他选项来使用它('labelName': { axis: {} } 似乎创建了另一个 Y 轴),虽然我还没有在文档中找不到它。

但是当尝试使用两个以上的 Y 轴时,我在日志中看到了这条消息:

dygraphs: Only two y-axes are supported at this time. (Trying to use 3) (stacktrace.js:31:25)

示例代码:

g = new Dygraph(
document.getElementById("demodiv"),
data, {
labels: ['Date', 'Y1', 'Y2', 'Y3', 'Y4'],
width: 640,
height: 350,
'Y3': {
axis: {}
},
'Y4': {
axis: 'Y3' // use the same y-axis as series Y3
},
xAxisLabelWidth: 100,
yAxisLabelWidth: 100,
axes: {
x: {
valueFormatter: function(ms) {
return 'xvf(' + new Date(ms).strftime('%Y-%m-%d') + ')';
},
axisLabelFormatter: function(d) {
return 'xalf(' + d.strftime('%Y-%m-%d') + ')';
},
pixelsPerLabel: 100,
},
y: {
valueFormatter: function(y) {
return 'yvf(' + y.toPrecision(2) + ')';
},
axisLabelFormatter: function(y) {
return 'yalf(' + y.toPrecision(2) + ')';
}
},
y2: {
valueFormatter: function(y2) {
return 'y2vf(' + y2.toPrecision(2) + ')';
},
axisLabelFormatter: function(y2) {
return 'y2alf(' + y2.toPrecision(2) + ')';
}
}
}
}
);

关于javascript - dygraphs 中超过 2 个 y 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26612516/

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