【问题标题】:Highcharts xrange chart is not respecting datetime xAxis min and max values - shows space on both sidesHighcharts xrange 图表不尊重日期时间 xAxis 最小值和最大值 - 在两侧显示空间
【发布时间】:2017-07-22 21:30:10
【问题描述】:

如何让我的图表尊重我设置的最小和最大 xAxis 值而不在左右两侧填充图表?我基本上想从最左边的最小 xAxis 值开始图表,并让它在最右边的最大 xAxis 值处结束,而两侧没有任何额外的填充/边距。

这是我正在使用的图表选项:

{
  "title": {
    "text": "Zone History"
  },
  "chart": {
    "type": "xrange",
  },
  "xAxis": {
    "type": "datetime",
    "min": 1500678032000,
    "max": 1500684162000,
    "startOnTick": false,
    "tickmarkplacement":"on",
  },
  "yAxis": {
    "title": "",
    "min": 0,
    "max": 0,
    "labels": {
      "enabled": false
    }
  },
  "tooltip": {},
  "credits": {
    "enabled": false
  },
  "plotOptions": {
    "series": {
      "grouping": false
    }
  },
  "noData": {
    "style": {
      "fontSize": "24px",
      "color": "#202030"
    }
  },
  "series": [
    {
      "name": "Zone 5",
      "data": [
        {
          "x": 1500677781000,
          "x2": 1500678032000,
          "y": 0
        }
      ],
      "_colorIndex": 0
    },
    {
      "name": "Zone 6",
      "data": [
        {
          "x": 1500678104000,
          "x2": 1500679562000,
          "y": 0
        },
        {
          "x": 1500682921000,
          "x2": 1500684162000,
          "y": 0
        }
      ],
      "_colorIndex": 1
    },
    {
      "name": "Zone 7",
      "data": [
        {
          "x": 1500679583000,
          "x2": 1500680765000,
          "y": 0
        }
      ],
      "_colorIndex": 2
    }
  ]
}

请参阅上面代码的当前版本包含的小提琴:http://jsfiddle.net/evgcbtrj/

感谢收看!

【问题讨论】:

    标签: javascript charts highcharts


    【解决方案1】:

    将 pointPlacement 设置为 'on' 应该可以帮助您摆脱图表两侧不必要的填充。

    plotOptions: {
      series: {
         pointPlacement: 'on'
      }
    }
    

    API 参考:
    http://api.highcharts.com/highcharts/plotOptions.series.pointPlacement

    示例:
    http://jsfiddle.net/nnt5t1ho/

    【讨论】:

      猜你喜欢
      • 2012-06-29
      • 2019-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-22
      • 2021-12-23
      • 2019-05-31
      • 1970-01-01
      相关资源
      最近更新 更多