Highcharts:带有垂直网格线的xAxis

Mon*_*uze 2 javascript highcharts

我需要创建一个折线图,其中xAxis将显示垂直网格线而不是水平网格线,就像"chart:{inverted:true}"情况一样(下面屏幕上的示例).

垂直网格线效应

遗憾的是,该解决方案并非"完全准确",因为它也会切换数据的顺序,因此实际上距离比例最终位于图表的一侧,而它应位于图表的底部,如下所示:

适当的数据顺序,但有水平网格线

我的问题是:有没有办法让网格线垂直显示而不切换数据的顺序?

这是Highcharts演示的示例图表,我想更改网格线的显示:

$(function () {
$('#container').highcharts({
    chart: {
        type: 'spline',
        inverted: false
    },
    xAxis: {
        reversed: false,
        labels: {
            formatter: function () {
                return this.value + 'km';
            }
        },
    },
    yAxis: {
        title: {
            text: 'Temperature'
        },
        labels: {
            formatter: function () {
                return this.value + '°';
            }
        },
    },
    legend: {
        enabled: false
    },
    series: [{
        name: 'Temperature',
        data: [[0, 15], [10, -50], [20, -56.5], [30, -46.5], [40, -22.1],
            [50, -2.5], [60, -27.7], [70, -55.7], [80, -76.5]]
    }]
});
Run Code Online (Sandbox Code Playgroud)

PS我宁愿不篡改传递给函数的数据的顺序.

Grz*_*ski 6

您是否考虑过使用xAxis.gridLineWidth和xAxis.gridLineColor参数? http://api.highcharts.com/highcharts/xAxis.gridLineWidth http://api.highcharts.com/highcharts/xAxis.gridLineColor

$(function() {
  $('#container').highcharts({
    chart: {
      type: 'spline',
      inverted: false
    },
    xAxis: {
      reversed: false,
      gridLineWidth: 1,
      labels: {
        formatter: function() {
          return this.value + 'km';
        }
      },
    },
    yAxis: {
      title: {
        text: 'Temperature'
      },
      gridLineWidth: 0,
      labels: {
        formatter: function() {
          return this.value + '°';
        }
      },
    },
    legend: {
      enabled: false
    },
    series: [{
      name: 'Temperature',
      data: [
        [0, 15],
        [10, -50],
        [20, -56.5],
        [30, -46.5],
        [40, -22.1],
        [50, -2.5],
        [60, -27.7],
        [70, -55.7],
        [80, -76.5]
      ]
    }]
  });
});
Run Code Online (Sandbox Code Playgroud)

在这里你可以看到一个如何工作的例子:http: //jsfiddle.net/r3wd8j7t/1/