gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 21:01:10 26 4
gpt4 key购买 nike

所以,我有一个页面用来监控一堆网络元素。我在一页上有 16 个单独的图表,有 5 分钟的数据点。

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

        $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 小时的数据。我想必须有一种更好、更有效的方法来实现这一目标?

最佳答案

我们遇到了同样的问题。
我们在 Github 上提交了一个问题,团队的 react 并不令人鼓舞。
https://github.com/amcharts/amcharts4/issues/2720

关于javascript - AmCharts 4 - 多个图表,与 3 相比非常慢,也许我可以做得更好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57482557/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com