简体   繁体   English

AmCharts4 - 无法加载文件

[英]AmCharts4 - Unable to load file

I'm showing a chart using AmCharts4 with the URL option to load the data from a PHP file in JSON format.我正在显示一个图表,使用 AmCharts4 和 URL 选项从 JSON 格式的 PHP 文件加载数据。 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 .在 javascript 控制台中,我看到消息: net::ERR.NETWORK_IO_SUSPENDED ,在图表中看到消息: 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.我在 web 上找不到类似的问题,因此非常感谢您的帮助。

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);
});

图表错误

You can try setting updateCurrentData to true, this shouldn't remove current data.您可以尝试将 updateCurrentData 设置为 true,这不应删除当前数据。

chartTotales.dataSource.updateCurrentData= true;

https://www.amcharts.com/docs/v4/reference/datasource/#updateCurrentData_property 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.还要检查浏览器工具中的网络选项卡,看看 API 的响应是什么。也许你遇到了速率限制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM