Reputation: 1
I'm showing a chart using AmCharts4 with the URL option to load the data from a PHP file in JSON format. The problem is that sometimes I have an error. In the javascript console, I see the message: net::ERR_NETWORK_IO_SUSPENDED
and in the chart the message: Unable to load file
. I need to reload the page to load the chart again. I'm not able to find a similar problem on the web, therefore I would be very grateful for help.
const chartTotales = am4core.create('chart-disponibilidad-pastel', am4charts.PieChart);
chartTotales.dataSource.url = 'backend/production.php?opc=4';
chartTotales.dataSource.reloadFrequency = 6000;
const pieSeries = chartTotales.series.push(new am4charts.PieSeries());
pieSeries.dataFields.value = 'horas';
pieSeries.dataFields.category = 'tipo';
pieSeries.dataFields.test = '0 min';
pieSeries.slices.template.stroke = am4core.color('#fff');
pieSeries.slices.template.strokeOpacity = 1;
pieSeries.labels.template.text = '{category} {test} {value.formatDuration(\'hh:mm:ss\')} Hrs';
pieSeries.slices.template.tooltipText = '{category} {value.formatDuration(\'hh:mm:ss\')}';
const colorSetTotal = new am4core.ColorSet();
//D72906
colorSetTotal.list = ['#F6F623', '#498561', '#D72906'].map( function(color) {
// @ts-ignore
return new am4core.color(color);
});
Upvotes: 0
Views: 130
Reputation: 39
You can try setting updateCurrentData to true, this shouldn't remove current data.
chartTotales.dataSource.updateCurrentData= true;
https://www.amcharts.com/docs/v4/reference/datasource/#updateCurrentData_property
Also check Network tab in browser tools to see what is in response from API. Maybe you are hitting rate limiter.
Upvotes: 1