具有较大变量数据的高图表并动态创建y轴

时间:2014-02-20 09:31:45

标签: jquery highcharts

我正在创建具有大量数据变量的高级图表,因为高级图表不显示最小数据我在这里使用日志来更改数据是我的代码工作正常但是y轴工作不正常这里是链接http://jsfiddle.net/rutup/6hxPU/ < / p>

    function createBarChart(source, title, placeHolderId, sideText, xColumnValue) {
Highcharts.setOptions({
    colors:["#1f77b4", "#ff7f0e", "#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f", "#bcbd22", "#17becf"]// ["#4572a7", "#aa4643", "#89a54e", "#80699b"]
});
$('#' + placeHolderId).highcharts({
    credits: { enabled: false },
    chart: {
        type: 'column'
    },
    exporting: { enabled: false },
    title: {
        text: title
    },

    xAxis: {
        categories: xColumnValue
    },

    legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'top',
        borderWidth: 0
    },
    yAxis: {
        min: 0,
       // tickInterval:
        lineWidth: 1,
        gridLineWidth: 0,
        title: {
            text: sideText
        },
        stackLabels: {
            enabled: true,
            style: {
                fontWeight: 'bold',
                color: 'gray'
            }
            , formatter: function () {
                return this.y;
            }
            //, formatter: function () {
            //    return calcTotalAntiLog(this.total);//this.total;
            //}
        }
    },
    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 :(得分:1)

您是否尝试使用对数轴并让highcharts计算日志? 在yAxis设置中设置type: 'logarithmic' 我已经修改了你的小提琴,以显示行动http://jsfiddle.net/6hxPU/7/