Move images rendered on highcharts on resize

前端 未结 2 593
礼貌的吻别
礼貌的吻别 2020-12-12 03:02

I\'m adding an image to the lower right hand corner of a chart in the chart loading event using the chartWidth and chartHeight properties to calculate the left / top offsets

2条回答
  •  醉梦人生
    2020-12-12 03:42

    I ended up storing a reference to the original width of the chart and the image. Then on resize, I'm shifting the image by the offset of the two widths -

    var img, originalWidth;
    
    function chartLoad(chart) {
      var top = 100, left = 100;
    
      originalWidth = chart.chartWidth;
      img = chart.renderer.image('img.png', left, top, 30, 30).add();
    }
    
    function chartResize(e) {
      var offset = e.target.chartWidth - originalWidth;
      img.translate(offset, 0);
    }
    

提交回复
热议问题