谷歌图表注释标签

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

[![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
ningruohai1 回答:谷歌图表注释标签

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/73244.html

大家都在问