0

我正在使用以下方法根据要求将注释标签从实际位置移动到底部位置。当我将鼠标悬停时加载谷歌图表后,注释标签从图表的底部移动到中心。请帮我解决这个问题。

[![https://i.stack.imgur.com/oiaYf.png][1]][1]

<google-chart [data]="chart.get(key)" #chartEl (chartReady)="onChartReady(chartEl)" 
   ></google-chart> 
   
   onChartReady(event:any) {
           const lableBoundx = 60;
           const lableBoundY = 6;
           let labels = event.el.nativeElement.querySelectorAll('text');
           Array.prototype.forEach.call(labels, function(label) {
           let labelBounds = label.getBBox();
               if (label.getAttribute('text-anchor') === 'middle') {
               label.setAttribute('text-anchor', 'start');
               label.setAttribute('x', parseFloat(label.getAttribute('x')) - lableBoundx - labelBounds.height);
               label.setAttribute('y', parseFloat(label.getAttribute('y')) - lableBoundY + labelBounds.height);
               label.style.pointerEvents = "none";
               }
            });
       }```


 [1]: https://i.stack.imgur.com/oiaYf.png
4

0 回答 0