代码之家  ›  专栏  ›  技术社区  ›  Peterhack

使用react获取highcharts中x轴的最大值

  •  0
  • Peterhack  · 技术社区  · 6 年前

    我在试着得到 max value of the x axis

    y: chart.xAxis[0].max-1
    

    here .

    1 回复  |  直到 6 年前
        1
  •  0
  •   ppotaczek    6 年前

    addAnnotation 方法:

      chart: {
        events: {
          load: function(){
            const chart = this;
    
            chart.addAnnotation({
                labels: [
                  {
                    point: {
                      x: 3,
                      y: chart.xAxis[0].max - 1,
                      xAxis: 0,
                      yAxis: 0
                    },
                    text: "x: {x}<br/>y: {y}"
                  },
                  {
                    point: {
                      x: 0,
                      y: 0
                    },
                    text: "x: {point.plotX} px<br/>y: {point.plotY} px"
                  },
                  {
                    point: {
                      x: 5,
                      y: 100,
                      xAxis: 0
                    },
                    text: "x: {x}<br/>y: {point.plotY} px"
                  }
                ],
                labelOptions: {
                  x: 40,
                  y: -10
                }
             })
           }
         }
       }
    

    https://codesandbox.io/s/537kz8xwyx