如何通过在海图甘特图中移动点图形来移动点的标签和SVG?

问题描述

在此example中,我尝试将点移动points.graphic.translate(0,-25),但它无助于移动点的标签和SVG。您可以在示例中查看详细信息。

events: {
        load() {

        var chart = this,series = chart.series[0];
        
        series.points.forEach(function(point) {
          point.graphic.translate(0,-25);
        });
      }
    }

解决方法

您需要分别移动每个元素。

标签:

  point.dataLabel.text.translate(0,-25)

渲染后的自定义图片:

  points.forEach(function(point) {
    point.customImg = chartt.renderer.image(
        'https://www.highcharts.com/images/employees2014/Torstein.jpg',point.plotX + chartt.plotLeft + point.shapeArgs.width / 2 - width / 2,point.plotY + chartt.plotTop - height / 2,width,height
      )
      .attr({
        zIndex: 5
      })
      .add();

    point.customImg.translate(0,-25)
  });

演示:https://jsfiddle.net/BlackLabel/05hmufxa/