Reputation: 8420
I use highcharts.js directly from:
<script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/modules/exporting.js"></script>
Suddenly, don't know since when, the data is not plotted anymore. I havne't made changes on the data, actually, in production enviroment and development, the charts are working the same way (same error) now since don't know when. There's no javascript error in console.
Somebody know if Highcharts has made recent changes that aren't compatible with a version of like 3 months ago?
I can see all the chart except the plotted data, like this:
I haven't changed those code in months.
This is how I call the charts:
console.log("seriesGraficos: ", seriesGraficos); //this is what the 2nd picture shows
Highcharts.chart({
chart: {
type: 'area',
renderTo: 'grafico_porcentaje_contratacion_vs_tiempo'
},
title: {
text: 'Contratación de Energía en el Tiempo'
},
xAxis: {
allowDecimals: false,
labels: {
formatter: function () {
return this.value;
}
}
},
yAxis: {
title: {
text: 'Cantidad de energía'
},
labels: {
formatter: function () {
return this.value + ' MWh';
}
}
},
plotOptions: {
area: {
pointStart: parseInt( anoInicio ),
marker: {
enabled: true,
symbol: 'circle',
radius: 2,
states: {
hover: {
enabled: true
}
}
}
}
},
series: seriesGraficos,
credits: {
enabled: false
},
exporting: {
chartOptions: {
chart: {
width: 1024,
height: 768
}
},
filename: "Energia Tiempo",
buttons: {
contextButton: {
text: 'Exportar'
}
}
}
});
When I click on some variable on the chart, I can see how it works as usual, when is enabled/disabled it moves the chart up and down a little bit. It's like the normal behavior.
In console.log I see all the needed data there:
Upvotes: 0
Views: 140
Reputation: 8420
Grrrr, it was the data type o the values of "data". If I use:
{"name": nameEnergiaContratadaA,"data": [344,2434,2434,514]},
{"name": nameDemandaA,"data": [34,234,234,54]}
console.log was showing it to me but I didn't get it... data: ["343", "2432", "etc numbers"...]
it all works again, I have to check where is the change from integer to char or whatever.
So a JSON.parse
when I was pushing the values to the arrays dataEnergiaContratadaA and dataDemandaA did the trick:
dataEnergiaContratadaA.push( JSON.parse(energia_asociada) );
dataDemandaA.push( JSON.parse(demanda) );
seriesGraficos.push(
{"name": nameEnergiaContratadaA,"data": dataEnergiaContratadaA},
{"name": nameDemandaA,"data": dataDemandaA}
);
Now console.log shows correct data:
Upvotes: 1