I want show empty/dummy bar chart when no data using amcharts version 4 as shown in below link using amcharts version 3.
Example with amcharts version 3
I have tried something like below, but getting error.
reChartData = am4core.create("exeChart", am4charts.XYChart);
var categoryAxis = reChartData.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = "";
var valueAxis = reChartData.yAxes.push(new am4charts.ValueAxis());
valueAxis.min = 0;
valueAxis.max = 100;
var dataPoint = {
dummyValue: 0
};
reChartData.data = dataPoint;
var series = reChartData.series.push(new am4charts.ColumnSeries());
series.dataFields.categoryX = "";
Error:
Error: Data fields for series "id-98" are not properly defined.
at e.validateData (charts.js:20)
at t.update (core.js:19)
at core.js:19
@GMStevents and @TonyMontana, can you please share your thoughts as you already discussed on similar issue here ?
Firstly, the error you get is because you are not defining your series dataFields. You need to specify the names of dataFields for your series. For example:
Secondly, the
XYChart.data
is an array. You cannot assign an object.Then to show a message on the chart when there is no data, create a container on the chart and add a label, like so:
See sample here