在xAxis highcharts上修复了许多标签

时间:2013-05-07 09:47:54

标签: jquery highcharts

我正在使用highcharts显示价格变化抛出ajax请求

http://jsfiddle.net/5wERK/(我改变了代码为你工作:))

var options = {
        chart: {
            renderTo: 'container',
            type: 'line',
            height: 80,
            width: 190,
            backgroundColor: '#EBEEEF'
        },
        title: {
            text: ''
        },
        xAxis: {
            type: 'datetime',
            labels: {
                style: {
                    fontSize: '9px'
                }
            }
        },
        yAxis: {

            title: {
                text: ''
            },
            labels: {
                style: {
                    fontSize: '9px'
                }
            }
        },
        plotOptions: {
            series: {
                marker: {
                    enabled: false
                }
            }
        },
        legend: {
            enabled: false
        },
        credits: {
            enabled: false
        },
        tooltip: {
            followPointer: true,
            formatter: function () {
                var p = Highcharts.numberFormat(this.y, 2, ',', ' ')
                var d = Highcharts.dateFormat('%d/%m/%Y', this.x)
                return d + '<br>' + p + ' €';
            }
        },
        series: [{
                color: '#646D70',
                data: [[1360598402000,299.99],[1360836003000,297.99],[1361037604000,309.99],[1361210401000,307.99],[1362470402000,308.22],[1362643202000,309.99],[1362762002000,308.22],[1363075202000,307.23],[1363248003000,308.99],[1363334402000,307.23],[1363366802000,312.19],[1363766402000,313.99],[1363798802000,309.99],[1363849202000,369.99],[1364025602000,299.99],[1364198402000,369.99],[1364241602000,455.00],[1364562003000,347.24],[1365145202000,337.38],[1365663602000,325.99],[1366387202000,337.00],[1366441202000,332.45],[1366700402000,381.75],[1367074803000,332.45],[1367229602000,381.75],[1367301602000,341.00],[1367388002000,346.00],[1367672402000,341.00]]
            }
        ]
    };
chart = new Highcharts.Chart(options);

在给定的例子中,xAxis上有2个标签,我想显示4,是否有解决方案?

感谢

2 个答案:

答案 0 :(得分:1)

您可以使用tickPixelInterval来增加标签数量。但是,要显示4,我认为您还需要增加图表本身的宽度。

http://jsfiddle.net/5wERK/4/

    var options = {
        xAxis: {
            tickPixelInterval: 50,
        }
    }

答案 1 :(得分:0)

您应该设置tickInverval,它允许定义刻度之间的距离。 http://api.highcharts.com/highcharts#xAxis.tickInterval