微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

谷歌图表注释标签

如何解决谷歌图表注释标签

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

[![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 举报,一经查实,本站将立刻删除。