在X轴上刻度位置

时间:2013-08-04 12:46:21

标签: javascript highcharts

如何限制在Highcharts中显示X轴上的刻度?最后一个是X轴的外部: enter image description here

我的来源:

var options = {
chart: {
    renderTo: 'chart',
    events: {
        load: function(event) {
        }
    },
    type: 'spline',
    animation: false
},
title: {
    text: ''
},
colors: [
    '#499878','black'
],
rangeSelector: {
    enabled: false
},
credits: {
    enabled: false
},
tooltip: {
    shared: true,
    crosshairs: true
},






series: [{
    name: 'Temperature (°C)',
    type: 'spline',
    tooltip : {
        valueDecimals: 2,
        valueSuffix: ' °C'
    },
    yAxis: 0,
    color: '#89A54E',
    data: []

},{
    name: 'Wind speed (m/s)',
    type: 'spline',
    tooltip : {
        valueDecimals: 2,
        valueSuffix: ' m/s'
    },
    yAxis: 1,
    color: '#4572A7',
    data: []
},{
    name: 'Humidity (%)',
    type: 'spline',
    tooltip : {
        valueDecimals: 2,
        valueSuffix: ' %'
    },
    yAxis: 2,
    color: '#910000',
    data: []
},{
    name: 'Wind direction (°)',
    type: 'spline',
    tooltip : {
        valueDecimals: 2,
        valueSuffix: ' °'
    },
    yAxis: 3,
    color: '#000000',
    dashStyle: 'shortdot',
    data: []
}],



xAxis: {
    type: 'datetime',
    tickInterval: 10000,
    min: 0,
    max: 0
},



yAxis: [{
    labels: {
        style: {
            color: '#89A54E'
        }
    },
    title: {
        text: 'Temperature',
        style: {
            color: '#89A54E'
        }
    },
    gridLineWidth: 1,
    opposite: true
},{
    labels: {
        formatter: function() {
            return this.value +' m/s';
        },
        style: {
            color: '#4572A7'
        }
    },
    title: {
        text: 'Wind speed',
        style: {
            color: '#4572A7'
        }
    },
    gridLineWidth: 1,
    opposite: false,
    min: 0
},{
    labels: {
        formatter: function() {
            return this.value +' %';
        },
        style: {
            color: '#910000'
        }
    },
    title: {
        text: 'Humidity',
        style: {
            color: '#910000'
        }
    },
    gridLineWidth: 1,
    opposite: true
},{
    labels: {
        formatter: function() {
            return this.value +' °';
        },
        style: {
            color: '#000000'
        }
    },
    title: {
        text: 'Wind direction',
        style: {
            color: '#000000'
        }
    },
    opposite: false,
    reversed: true,
    min: 0,
    max: 360,

    minorGridLineDashStyle: 'longdash',
    minorTickInterval: 'auto',
    minorTickWidth: 0,
    tickInterval: 90
}],




plotOptions: {
    spline: {
        lineWidth: 3,
        states: {
            hover: {
                lineWidth: 5
            }
        },
        marker: {
            enabled: false
        }
    },
    scatter: {
        marker: {
            enabled: true
         }
    }
}
};

2 个答案:

答案 0 :(得分:0)

我发现它是oveflow: 'justify'的问题。 jsfiddle

答案 1 :(得分:-1)

如果您使用'spacingRight'(http://api.highcharts.com/highcharts#chart.spacingRight),会发生以下情况:

chart: {
    renderTo: 'chart',
    events: {
        load: function(event) {
        }
    },
    type: 'spline',
    animation: false,
    spacingRight: 100 // you may change this for testing...
},