I´m trying to use in solid gauge a data array, created previously. The problem is: when I use the setInterval function to update the point´s values,dynamically, my array update it's first element to current value.
I've tried some solutions like duplicate my array, clone it, even reassignment the first value again but nothing work, the value always change, I think it's by refence but where? Example: The array is:
fullData=[[{y:25},{y:87}],[{y:73},{y:154}]]
when the setInterval run the array update it's first value position as:
fullData=[[{y:440},{y:239}],[{y:200},{y:320}]]
This is an example: https://jsfiddle.net/asonipse/nsvt0jb3/1/3
var fullData = [
[{
'name': 'A',
'innerRadius': 50,
'radius': 70,
'y': 440
}, {
'name': 'E',
'innerRadius': 70,
'radius': 100,
'y': 239
}],
[{
'name': 'A',
'innerRadius': 50,
'radius': 70,
'y': 200
}, {
'name': 'E',
'innerRadius': 70,
'radius': 100,
'y': 320
}]
],
cont = 1,
series = [];
series.push({
'name': 'Name serie',
'data': fullData[0],
'dataLabels': false
});
var gaugeOptions = {
chart: {
type: 'solidgauge',
},
title: {
text: 'Ejemplo'
},
tooltip: {
enabled: true,
pointFormat: '{point.name}: <b>{point.y}</b>'
},
pane: {
center: ['50%', '85%'],
size: '150%',
startAngle: -90,
endAngle: 90,
background: {
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
innerRadius: '50%',
outerRadius: '100%',
shape: 'arc'
}
},
// the value axis
yAxis: {
min: 0,
max: 440,
lineWidth: 0,
minorTickInterval: null,
tickPixelInterval: 400,
tickWidth: 0,
tickAmount: null,
},
plotOptions: {
solidgauge: {
dataLabels: {
y: 5,
borderWidth: 0,
useHTML: true
}
}
},
};
$('#container-speed').highcharts(Highcharts.merge(gaugeOptions, {
credits: {
enabled: false
},
series: series
}), function(chart) {
if (!chart.renderer.forExport) {
setInterval(function() {
if (chart && chart.series) {
chart.series[0].setData(fullData[cont]);
cont = (cont + 1 === 2) ? 0 : cont + 1;
}
}, 2000);
}
});