使用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'
}
}
});
效果圖如下: