i'm new in JS and highcharts. I'm trying to get the solid Gauge data value from a simple item list. But it doesn't seem to work. The list is an AJAX response[]. Apparently the value must be inserted between '[]' still no data displayed. what's the problem in my code?
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: '%'
}
}]
});
});
The type of your value
variable is string
and from my point of view the value passes to the series.data
should be a real array.
You can transform a "array-like" string to an array like below (assume your response[0]
is like "a,b,c"
):
var value = response[0].split(',');
If this doesn't solve your problem, I suggest that you put more code, like what exactly response[0]
is and what is printed in the console
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.