使用HighCharts时,若数据为空, 图中会显示一大块空白,特别难看, 因此需要添加一条提示.
用于显示一条像“没有要显示的数据”的选项。这个特性需要在页面头部加载no-data-to-display.js文件。真正显示出的文本是在 lang.noData 设置的。
$('#container').highcharts({
title: {
text: 'No data in line chart - with custom options'
},
series: [{
type: 'line',
name: 'Random data',
data: []
}],
lang: {
noData: "Nichts zu anzeigen" //真正显示的文本
},
noData: {
// Custom positioning/aligning options
position: { //相对于绘图区定位无数据标签的位置。 默认值:[object Object].
//align: 'right',
//verticalAlign: 'bottom'
},
// Custom svg attributes
attr: { //无数据标签中额外的SVG属性
//'stroke-width': 1,
//stroke: '#cccccc'
},
// Custom css
style: { //对无数据标签的CSS样式。 默认值:[object Object].
//fontWeight: 'bold',
//fontSize: '15px',
//color: '#202030'
}
}
});
效果图如下: