gpt4 book ai didi

javascript - 如何在jquery flot图中用字符串替换变量

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

我正在使用 Flot 线图,它工作正常:

data1 = [
[1430369878000, 1690.25],
[1430369879000, 1696.3],
[1430369880000, 1659.65]

];


data2 = [
[1430369878000, 1682.1],
[1430369879000, 1680.65],
[1430369880000, 1685.1]

];

但是当我将 data1 和 data2 替换为:

 dataset = [{
label: "Team Red",
data: [
[1430369878000, 1690.25],
[1430369879000, 1696.3],
[1430369880000, 1659.65]
],
color: "#FF0000",
points: {
fillColor: "#FF0000",
show: true
},
lines: {
show: true
}
}, {
label: "Team Blue",
data: [
[1430369878000, 1682.1],
[1430369879000, 1680.65],
[1430369880000, 1685.1],
color: "#0062E3",
points: {
fillColor: "#0062E3",
show: true
},
lines: {
show: true
}
}
];

它根本不起作用,我做错了什么?

最佳答案

您的第二个 data 值缺少右方括号。试试这个:

dataset = [
{
label: "Team Red",
data: [
[1430369878000, 1690.25],
[1430369879000, 1696.3],
[1430369880000, 1659.65]
],
color: "#FF0000",
points: {
fillColor: "#FF0000",
show: true
},
lines: {
show: true
}
}, {
label: "Team Blue",
data: [
[1430369878000, 1682.1],
[1430369879000, 1680.65],
[1430369880000, 1685.1]
],
color: "#0062E3",
points: {
fillColor: "#0062E3",
show: true
},
lines: {
show: true
}
}
];

关于javascript - 如何在jquery flot图中用字符串替换变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30022697/

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