如何在高图中水平对齐标题html div与图表?

时间:2017-10-19 22:00:10

标签: javascript html css highcharts

考虑以下jsfiddle

enter image description here

我正在努力调整标题bottom-border与图表之间的差距。优选地,图表的左侧和右侧分别与标题边框的左侧和右侧对齐。

无论如何,我可以在没有硬编码的情况下做到这一点(我的图表宽度相对于屏幕尺寸而变化)?

2 个答案:

答案 0 :(得分:1)

您可以强制标题与绘图区域具有相同的宽度和左侧偏移。要确保其响应,请使用render事件:

chart: {
  plotBorderWidth: 1,
  events: {
    render: function() {
      var style = this.title.element.style;
      style.left = this.plotLeft + 'px';
      style.width = this.plotWidth + 'px';
    }
  }
}

实时工作演示: http://jsfiddle.net/kkulig/y3fj6vpq/

API参考: https://api.highcharts.com/highcharts/chart.events.render

答案 1 :(得分:-1)

更改标题的这两个属性。

left: 77px;
width: 922px;
相关问题