gpt4 book ai didi

javascript - 优雅地处理没有数据的 amcharts

转载 作者:行者123 更新时间:2023-11-30 10:05:32 25 4
gpt4 key购买 nike

我想知道我的 dataProvider 是否为空。 amCharts 绘制时默认为 null。我该如何动态处理它。

var chart = AmCharts.makeChart("chartdiv", {
"theme": "none",
"type": "serial",
"dataProvider": data,
"valueAxes": [{
"title": "Income in millions, USD"
}]

如果数据应该为空。怎么处理它..

最佳答案

这里有两个真正的选择。

您可以做的第一件事是在调用 AmCharts.makeChart() 之前检查数据,并且只有在有数据时才执行该函数。如果没有任何数据,您可能希望向用户显示某种消息。

您的第二个选择是在图表本身上显示一条消息。 Here is an example on the AmCharts website that can help achieve this.

关于javascript - 优雅地处理没有数据的 amcharts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29361767/

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