从十字准线到工具提示的高度图表距离

时间:2019-01-29 15:53:36

标签: javascript typescript highcharts

在Highcharts线性图中,我启用了格式化的工具提示和十字线。工具提示和十字准线之间的距离很大,因此会出现一个间隙(用红色标记):

enter image description here

设置

tooltip: {
    distance: 1
}

从视觉上解决了问题,但随后出现编译器错误:  对象文字可能仅指定已知属性,并且在“工具提示选项”类型中不存在“距离”

有没有其他方法可以使工具提示和十字准线之间的距离最小?

这些是我关于工具提示的图表选项:

tooltip: {
    headerFormat: '',
    useHTML: true,
    backgroundColor: null,
    borderWidth: 0,
    shadow: false,
    shape: 'square',
    pointFormatter: function() {
      return '<div style="background-color:'+this.series.color+';color:white;padding:5px;font-size:12px;z-index:10">' + this.y.toLocaleString() + ' %</div>'
    },
    split: true,
    crosshairs: {
      color: '#333333',
      dashStyle: 'solid',
      width: 2,
    },
  },

1 个答案:

答案 0 :(得分:0)

此空间是由padding属性的默认值引起的,可以通过以下方式减小它:

tooltip: {
    ...,
    padding: -8
}

实时演示:http://jsfiddle.net/BlackLabel/6m4e8x0y/2098/

API参考:https://api.highcharts.com/highstock/tooltip.padding