HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// create chart
3
var chart = anychart.column([["A", 1], ["B", 2], ["C", 3],]);
4
5
// enable no data label
6
chart.noData().label(true);
7
8
// handle event and prevent showing on showing legend
9
chart.listen("dataChanged", function(event){
10
// prevents no data label from showing when
11
// there no data to show on the chart
12
// ie series are hidden using legend
13
14
if (!event.hasData) {
15
event.preventDefault();
16
}
17
});
18
19
// enable legend
20
chart.legend(true);
21
// chart title
22
chart.title("No Data: Prevent showing")
23
// display chart
24
chart.container("container").draw();
25
});