优雅地处理没有数据的amcharts [英] Gracefully handle amcharts that have no data

查看:80
本文介绍了优雅地处理没有数据的amcharts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want know if my dataProvider is empty. When amCharts draw default null. How can i handle it dynamically.

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

如果数据应该为空.怎么处理呢?.

If data should empty. How could be handle it..

推荐答案

您在这里有两个实际选择.

You have two real options here.

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

The first thing you can do is check for data before calling AmCharts.makeChart() and only execute that function if there is data. You will probably want to show some kind of message to the user in the event there isnt any data.

您的第二个选择是在图表本身上显示一条消息. AmCharts网站上的示例可以帮助实现这一目标.

Your second option is to display a message on the chart itself. Here is an example on the AmCharts website that can help achieve this.

这篇关于优雅地处理没有数据的amcharts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆