谷歌图表注释标签

问题描述

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

[![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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)