如何将标签放置在仪表左侧?

问题描述 投票:0回答:1

我试图将零数字放在仪表之外,但我不知道该怎么做,我无法使用 x 和 y 选项,因为绘图线的位置总是在变化,所以我需要移动零与plotLine一起并且始终在外面。this is a gauge where the zero is higher than the start of the gauge.in this case the gauge is right where the gauge starts, here you can see how the zero is positioned.

这里我将留下我认为相关的代码部分

    yAxis: {
      reversed: false,
      min: min || 0,
      max: max || 1,
      lineWidth: 0,
      tickInterval: 0,
      tickWidth: 0,
      tickColor: "transparent",
      minorTickInterval: null,
      zIndex: 4,
      tickAmount: 2,
      title: {
        y: -90,
      },
      labels: {
        y: 20,
        distance: -25,
        style: {
          color: activeColor, // muiTheme.palette.common.coal[0],
          fontSize: "14px",
        },
      },
      plotBands: [
        {
          from: plotBandValueFrom,
          to: plotBandValueTo,
          borderColor: "#000",
          backgroundColor: "transparent",
          borderWidth: 2,
          thickness: "100%",
          outerRadius: "80%",
          innerRadius: "60%",
          zIndex: 10,
        },
      ],
      plotLines: [
        {
          value: 0,
          zIndex: 5,
          width: 4,
          color: "#000",
          label: {
            text: 0,
            verticalAlign: "top",
            textAlign: "center",
            style: {
              color: "#000",
              fontSize: "10px",
            },
          },
        },
      ],
    },
reactjs typescript highcharts
1个回答
0
投票

不幸的是,无法使用 API 中的属性以这种方式定位标签。但是,您可以使用

chart.events.render()
回调按照您自己的逻辑更新位置。下面的演示并不完美,但是是如何实现这一点的示例。

演示https://jsfiddle.net/BlackLabel/ud9rjmfL/ APIhttps://api.highcharts.com/highcharts/chart.events.render

© www.soinside.com 2019 - 2024. All rights reserved.