gpt4 book ai didi

javascript - 如何用 jqplot 绘制系列的子集?

转载 作者:行者123 更新时间:2023-11-28 00:55:44 24 4
gpt4 key购买 nike

我需要在同一张 Canvas 上绘制三个系列。该系列类似于:

rec1 = [0,  0,   150, 200, 0  ];
rec2 = [60, 120, 179, 240, 300];
rec3 = [50, 100, 150, 200, 250];

我使用下面的源代码来绘制该系列。

$.jqplot("chart", [rec1, rec2, rec3], {
title: "",
axesDefaults: {
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: {
fontSize: '10pt'
}
},
seriesDefaults: {
rendererOptions: {
smooth: false
},
pointLabels: {
show: true,
ypadding: 10
},
showMarker: true,
lineWidth: 2
},
legend: {
show: true,
location: 'nw',
placement: "outside"
}
});

在rec1中,具有零值的元素将始终为零。我想将这些零值元素隐藏在rec1中。有什么办法可以实现这一点吗?将rec1设置为:

rec1 = [undefined, undefined, 150, 200, undefined]

会隐藏这些未定义的点,但会导致150和200的点标 checkout 现在错误的位置,如图所示。感谢您提供任何有用的指导。

enter image description here

最佳答案

您应该使用二维数组来放置点,而不是使用“平面”数组:

rec1 = [[3, 150], [4, 200] ]; // we defined 2 points with their (x, y) coordinates
rec2 = [60, 120, 179, 240, 300];
rec3 = [50, 100, 150, 200, 250];

我制作了一个 jsfiddle 来显示这一点(我刚刚将点 [3, 150] 从您的示例中移动到 [3, 90] ,以便您看到其标签的正确位置):http://jsfiddle.net/5wgcqyet/1/

关于javascript - 如何用 jqplot 绘制系列的子集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26250916/

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