[英]Facing issue in chart size while I am trying to use billboard.js chart library with Angular 6
I am trying to use billboard.js chart library with Angular 6 and facing issue in chart size.我正在尝试将 billboard.js 图表库与 Angular 6 结合使用,但面临图表大小的问题。 When the page load for first time, chart size is bigger than it's div container and when i change browser window size, chart's size is automatically adjusted according to div container.
当页面第一次加载时,图表大小大于它的 div 容器,当我改变浏览器窗口大小时,图表的大小会根据 div 容器自动调整。
See the screenshot before and after window resize.查看窗口调整大小前后的屏幕截图。
I have tried to lazy load graph as mentioned here , but it's not working.我曾尝试像这里提到的那样延迟加载图,但它不起作用。
Any help would be appreciated.任何帮助,将不胜感激。
Import AfterViewInit
and add this method to the class.导入
AfterViewInit
并将此方法添加到类中。 This line of code resizes the chart after the chart is rendered.这行代码在图表呈现后调整图表的大小。
ngAfterViewInit() {
this.charts[0].resize();
}
You can also specify height and width to the resize function to resize chart to a specific size.您还可以为调整大小函数指定高度和宽度以将图表调整为特定大小。
resize({height: '200px', width: '400px'});
Check the documentation here - https://naver.github.io/billboard.js/release/latest/doc/Chart.html#resize检查此处的文档 - https://naver.github.io/billboard.js/release/latest/doc/Chart.html#resize
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.