I am currently working on my first Ionic App and is working with Angular for the first time.
I am using a pie chart library to display charts in the application toolbar. This works well if I update when I'm on the toolbar, and looks like this:
https://imgur.com/YUCAO6i,oakGp8c#1
But if I go to another tab, say, the server tab and update there, the width and height will not be applied to the charts in the control panel. Instead, they are displayed using standard widths and heights (500 x 900 W instead of 100 x 100 W). (See second image on imgur). If I update again on the toolbar, they will be displayed as usual.
I looked at the source code of the library and saw that when updating in the control panel, the [0] .parentElement.offsetWidth element is 100, but if I update in a different view, it is 0, so the default values ββare used. It seems that the pie-chart directive cannot access the parent when it is in a different view.
Here is the HTML and CSS:
HTML
<div class="pieChart"> <pie-chart data="server.chartData.cpu" options="chartOptions"></pie-chart> </div>
CSS
.pieChart { height: 100px; width: 100px; float: left; }
I tried to find the answer for hours, but I'm not even sure what exactly I need to look for. The only solution I came across was to change the default value in pie-chart.js, which I would rather not do.
EDIT
An open source application, you can find the full code in my repository: https://github.com/AndreasGassmann/cloudatcostapp