Tip: Show the main range of data

Below code will help to show only main range of data, the rest data which are not interested will be represented with same value but the actual data would be reflected in tooltip

http://jsfiddle.net/4NV2J/6/

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'spline'
        },
        title: {
            text: 'Y axis'
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },        
        yAxis: {
            tickInterval: 1,
            min: -1,
            max: 6,
            title: {
                text: 'Value'
            },
            labels: {
                formatter: function() {
                    if(this.isFirst) {
                        return '< 0';
                    } else if (this.isLast) {
                        return '> 5';
                    } else {
                         return this.value;   
                    }
                }
            }
        },
        tooltip: {
            pointFormat:  '<span style="color:{series.color}">\u25CF</span> {series.name}: <b>{point.options.trueValue}</b><br/>'   
        },
        series: [{
            data: [{
                y: 3,
                trueValue: 3
            }, {
                y: 4,
                trueValue: 4 
            }, {
                y: -1,
                trueValue: -4 
            }, {
                y: 6,
                trueValue: 40
            }]        
        }]
    });
});

  

 

posted @ 2015-05-21 14:18  rongbin  阅读(133)  评论(0编辑  收藏  举报