在highcharts底部的空间

时间:2016-10-03 15:01:01

标签: javascript highcharts

我有以下highcharts设置,xAxis上方底部有一个空格,有人可以告诉我解决此偏移的最佳方法对我来说不是解决方案。

$(function() {
  $('#container').highcharts({
    chart: {
      type: 'column',
      animation: true,
      verticalAlign: 'bottom',
      backgroundColor: "#ffffff"
    },
    legend: {
      enabled: true,
      verticalAlign: 'bottom',
      align: 'center',
    },
    xAxis: {
      type: 'datetime',
      //tickInterval: 3600 * 1000,
      //min: Date.UTC(2016, 9, 3),
      //max: Date.UTC(2016, 9, 4),
      dateTimeLabelFormats: {
        day: '%H'
      }
    },
    yAxis: {
      title: {
        text: null
      },
      minPadding: 0,
      maxPadding: 0,
       min: 0,
            max: 3,
      minRange: 0.1,
      tickInterval: 1,
      gridLineWidth: 0,
      categories: ["", "Short", "Medium", "High", "Long"],
    },
    colors: ["#bb2e33", "#fac300", "#68a92a"],
    series: [{
      name: 'Severe',
      pointStart: Date.UTC(2016, 9, 3),
      pointInterval: 24 * 3600 * 1000,
      data: [
        [1475482200000, 3],
        [1475489685000, 1],
        [1475489693000, 1],
        [1475489704000, 1],
        [1475490071000, 3]
      ],
      //stack: 'week'
    }, {
      name: 'Moderate',
      pointStart: Date.UTC(2016, 9, 3),
      pointInterval: 24 * 3600 * 1000,
      data: [
        [1475472600000, 2],
        [1475489685000, 2],
        [1475489693000, 2],
        [1475489704000, 2],
        [1475490071000, 2],
        [1475490071000, 2],
        [1475490071000, 1]
      ],
      //stack: 'week'
    }, {
      name: 'Mild',
      pointStart: Date.UTC(2016, 9, 3),
      pointInterval: 24 * 3600 * 1000,
      data: [
        [1475472600000, 1],
        [1475489685000, 3],
        [1475489693000, 2],
        [1475489704000, 1],
        [1475490071000, 1]
      ],
      //stack: 'week'
    }]
  });
});

以下示例 http://jsfiddle.net/93Xcu/373/

1 个答案:

答案 0 :(得分:1)

我认为,对于您的图表,您可以使用pointPlacement参数,以便按照您的需要设置列位置:

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

您可以在此处阅读Highcharts API中的此参数 http://api.highcharts.com/highcharts/plotOptions.column.pointPlacement

在这里,您可以看到一个如何运作的示例:http://jsfiddle.net/93Xcu/374/