gpt4 book ai didi

javascript - 如何从 JS 变量获取 Highcharts 实体仪表数据?

转载 作者:行者123 更新时间:2023-12-03 07:02:52 24 4
gpt4 key购买 nike

我是 JS 和 highcharts 的新手。我正在尝试从简单的项目列表中获取可靠的仪表数据值。但这似乎不起作用。该列表是 AJAX 响应[]。显然该值必须插入“[]”之间,但仍然没有显示数据。我的代码有什么问题?

var value = '['+response[0]+']';

$('#rquest').append(response[0]);
$('#response').highcharts({
chart: {
type: 'gauge',
plotBackgroundColor: null,
plotBackgroundImage: null,
plotBorderWidth: 0,
plotShadow: false
},
pane: {
startAngle: -150,
endAngle: 150

},
// the value axis
yAxis: {
min: 0,
max: 100,
minorTickInterval: 'auto',
minorTickWidth: 1,
minorTickLength: 10,
minorTickPosition: 'inside',
minorTickColor: '#666',
tickPixelInterval: 30,
tickWidth: 2,
tickPosition: 'inside',
tickLength: 10,
tickColor: '#666',
labels: {
step: 2,
rotation: 'auto'
},
title: {
text: '%'
},
plotBands: [{
from: 0,
to: 30,
color: '#DF5353' // red
}, {
from: 30,
to: 60,
color: '#55BF3B' // yellow
}, {
from: 60,
to: 100,
color: '#DF5353' // red
}]
},
series: [{
name: 'Speed',
data: value,
tooltip: {
valueSuffix: '%'
}
}]
});
});

最佳答案

您的value变量的类型是string,从我的 Angular 来看,传递给series.data的值应该是真实的大批。

您可以将“类似数组”的字符串转换为如下所示的数组(假设您的 response[0] 类似于 “a,b,c”):

var value = response[0].split(',');

如果这不能解决您的问题,我建议您添加更多代码,例如 response[0] 到底是什么以及 console 中打印的内容。 ..

关于javascript - 如何从 JS 变量获取 Highcharts 实体仪表数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36957246/

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