AmCharts 4-多个图表,与3相比非常慢,也许我可以做得更好?

时间:2019-08-13 17:22:16

标签: javascript amcharts4

因此,我有一个页面用来监视一堆网络元素。我在一页上有16个单独的图形,并有5分钟的数据点。

我有一个while循环来构建像这样的javascript。

        $script .= '<!-- Chart code -->

am4core.ready(function() {

// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end

// Create chart instance
var chart = am4core.create("'.$agcname.'", am4charts.XYChart);


// Add data
chart.data = ['.rtrim($oosdata,',').'];

// Set input format for the dates
chart.dateFormatter.inputDateFormat = "yyyy-MM-dd HH:mm";

// Create axes
var dateAxis = chart.xAxes.push(new am4charts.DateAxis());
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
var avgAxis = chart.yAxes.push(new am4charts.ValueAxis());

// Create series
var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.valueY = "oosmta";
series.dataFields.dateX = "date";
series.tooltipText = "{value}"
series.strokeWidth = 2;
series.minBulletDistance = 1;

// Create series
var average = chart.series.push(new am4charts.LineSeries());
average.dataFields.valueY = "avg";
average.dataFields.dateX = "date";
average.tooltipText = "{value}"
average.strokeWidth = 1;
average.stroke = am4core.color("DEFDEF");
average.minBulletDistance = 20;



}); // end am4core.ready() // end am4core.ready()
';

一张图上的数据样本。

// Add data
chart.data = [{
"date": "2019-08-13 04:20",
"oosmta": 5871,
"avg": 5966
}, {
"date": "2019-08-13 04:25",
"oosmta": 5876,
"avg": 5966
}, {
"date": "2019-08-13 04:30",
"oosmta": 5885,
"avg": 5966
}, {
"date": "2019-08-13 04:35",
"oosmta": 5872,
"avg": 5966
}, {
"date": "2019-08-13 04:40",
"oosmta": 5870,
"avg": 5966
}];

每张图我显示6个小时的数据。我想必须要有一种更好,更有效的方法来实现这一目标?

1 个答案:

答案 0 :(得分:0)

我们遇到了同样的问题。

我们在Github上发布了一个问题,团队的反应并不令人鼓舞。

https://github.com/amcharts/amcharts4/issues/2720