When I click back and forth between tabs, I only want to do one click. It works great for displaying text but it requires two clicks for the chart. Is there a way to solve this?
I get this error "Failed to create chart: can't acquire context from the given item" the first click. Then the second click works.
Notes: I have the create chart function in charts.ts and export it in get-stock-list.component.ts. The HTML below is from my get-stock-list.component.html file.
I'm using Chart.js for my chart library. Code attached.
<div class="container"> <div class="tab"> <ul> <li id="volume" (click)="tabChange('volume')">Daily Volume </li> <li id="price" (click)="tabChange('price')">Daily Average Price</li> <li id="">Daily Chart</li> </ul> </div> </div> <div class="content"> <div class="content-value" *ngIf="id === 'volume'"> <canvas id="volume-canvas"></canvas> </div> <div class="content-value" *ngIf="id === 'price'"> <!-- insert price chart here --> </div> </div>