当所有值均为0高位图时,堆积条形图显示悬挂零

时间:2014-02-27 11:11:47

标签: jquery highcharts

我正在使用叠条高图。当所有数据为零时,它显示挂0,但当其中至少有一个具有适当的值时,它显示0粘在y轴上。我希望这也适用于整个数据为0时请参考     http://jsfiddle.net/rutup/6hxPU/8/

 function createBarChart(source, title, placeHolderId, sideText, xColumnValue) {


$('#' + placeHolderId).highcharts({
    credits: { enabled: false },
    chart: {
        type: 'column'
    },
    exporting: { enabled: false },
    title: {
        text: false
    },

    xAxis: {
        categories: xColumnValue
    },

    legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'top',
        y:20,
        borderWidth: 0
    },
    yAxis: {
        min: 0,
        //type: 'logarithmic',
        //tickInterval:
        lineWidth: 0,
        gridLineWidth: 0,
        title: {
            text: sideText
        },
        labels: {
            enabled: false
        },
        stackLabels: {
            enabled: true,
            style: {
                fontWeight: 'bold',
                color: 'gray'
            }
            , formatter: function () {
                return calcTotalAntiLog2(this);
            }
        }
    },
    tooltip: {
        formatter: function () {
            return '<b>' + this.x + '</b><br/>' +
                this.series.name + ': ' + calcAntiLog(this.y) //+ '<br/>' +//calcAntiLog(this.y)
            // 'Total: ' + calcAntiLog(this.point.stackTotal);//calcAntiLog(this.point.stackTotal)
        }
    },
    plotOptions: {
        column: {
            stacking: 'normal',
            dataLabels: {
                color: 'white',
                enabled: true,
                formatter: function () {
                    return calcAntiLog(this.y);
                }
            }
        }
    },
    series: source
});

}

1 个答案:

答案 0 :(得分:0)

只需为yAxis设置minRange即可。例如:http://jsfiddle.net/6hxPU/14/

相关问题