HighCharts中无数据时,添加提示

使用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'          
            }  
        }
    });

效果图如下:
这里写图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章