0

我正在使用 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,有解决方案吗?

谢谢

4

2 回答 2

1

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

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

    var options = {
        xAxis: {
            tickPixelInterval: 50,
        }
    }
于 2013-05-07T11:14:02.857 回答
0

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

于 2013-05-07T12:02:50.180 回答