javascript 在气泡图的中心标记图例

lc8prwob  于 2023-09-29  发布在  Java
关注(0)|答案(1)|浏览(87)

我在玩这张图表:
https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/demo/packed-bubble-split
Package 气泡分裂,我想使传说(AsiaEurope等)出现在每个气泡的中心。events可以吗?我试过这样的东西:

Highcharts.chart(chartContainer, {
    chart: {
        type: 'packedbubble',
        renderTo: chartContainer,
        events: {
            render: function() {
                const chart = this;
                chart.series.forEach(function (series) {
                    var data = series.data; // Get all the data points for the series
                    var totalX = 0;
                    var totalY = 0;
                    var totalPoints = data.length;

                    // Calculate the total X and Y coordinates of the data points
                   
                        })
                        .add();
                });
            }
        }
    },

不走运,我不能把它们放在中间。我想知道是否有一种方法可以实现它。

8fsztsew

8fsztsew1#

您可以使用下面的插件,它将添加所需的自定义标签,并在动画过程中定位它。

(function(H) {
    . . . .
    series.customLabel.attr({
      x: series.parentNode.plotX + chart.plotLeft,
      y: series.parentNode.plotY + chart.plotTop - 10
    });
  });
}(Highcharts));

现场演示:https://jsfiddle.net/BlackLabel/v1ew6bLc/
文档:https://www.highcharts.com/docs/extending-highcharts/extending-highcharts

相关问题