从数据库中获取数据后,我想将其传递给系列:highchart。下面是数据。
series: [
// { name: '53411', data:[8151.74,15105.39]},
// { name: '53473', data:[18703.18,6692.23]},
// { name: '500606', data:[-866.78,1311.01]},
// { name: '500613', data:[27621.01,68468.79]},
// { name: '500614', data:[73.3,80.47]}
]
但我希望这是动态创建的,为此我所做的也在下面:
var seriesData = '';
for (var i = 0; i < data.length; i++) {
if (i == data.length - 1) {
seriesData += "{ name:'" + seriesProviderName[i] + "', data:[" + providerist[i] + "," + providersec[i] + "]}";
}
else {
seriesData += "{ name:'" + seriesProviderName[i] + "', data:[" + providerist[i] + "," + providersec[i] + "]},";
}
之后我将这个 seriesData 传递给Series: [seriesData]
但它不会打印图表。因为它是一个字符串,它在开头和结尾包含双引号,我在萤火虫中看到过它,我不知道如何摆脱它。例如,“seriedData”这是在萤火虫中。
"{ name: '53411', data: [8151.74,15105.39]},
{ name: '53473', data: [18703.18,6692.23]},
{ name: '500606', data: [-866.78,1311.01]},
{ name: '500613', data: [27621.01,68468.79]},
{ name: '500614', data: [73.3,80.47]}
"
我想删除这些双引号。