Browse Source

fix(ts): reinforce chart type safety

pull/4209/head
KenTandrian 7 months ago
parent
commit
7777ae113e
  1. 8
      libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts
  2. 2
      libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

8
libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts

@ -77,7 +77,7 @@ export class GfPortfolioProportionChartComponent
@ViewChild('chartCanvas') chartCanvas: ElementRef<HTMLCanvasElement>; @ViewChild('chartCanvas') chartCanvas: ElementRef<HTMLCanvasElement>;
public chart: Chart<'pie'>; public chart: Chart<'doughnut'>;
public isLoading = true; public isLoading = true;
private readonly OTHER_KEY = 'OTHER'; private readonly OTHER_KEY = 'OTHER';
@ -257,7 +257,7 @@ export class GfPortfolioProportionChartComponent
}); });
}); });
const datasets: ChartConfiguration['data']['datasets'] = [ const datasets: ChartConfiguration<'doughnut'>['data']['datasets'] = [
{ {
backgroundColor: chartDataSorted.map(([, item]) => { backgroundColor: chartDataSorted.map(([, item]) => {
return item.color; return item.color;
@ -295,7 +295,7 @@ export class GfPortfolioProportionChartComponent
datasets[1].data[1] = Number.MAX_SAFE_INTEGER; datasets[1].data[1] = Number.MAX_SAFE_INTEGER;
} }
const data: ChartConfiguration['data'] = { const data: ChartConfiguration<'doughnut'>['data'] = {
datasets, datasets,
labels labels
}; };
@ -308,7 +308,7 @@ export class GfPortfolioProportionChartComponent
) as unknown; ) as unknown;
this.chart.update(); this.chart.update();
} else { } else {
this.chart = new Chart(this.chartCanvas.nativeElement, { this.chart = new Chart<'doughnut'>(this.chartCanvas.nativeElement, {
data, data,
options: { options: {
animation: false, animation: false,

2
libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

@ -196,7 +196,7 @@ export class GfTreemapChartComponent
min: Math.min(...negativeNetPerformancePercents) min: Math.min(...negativeNetPerformancePercents)
}; };
const data: ChartConfiguration['data'] = { const data: ChartConfiguration<'treemap'>['data'] = {
datasets: [ datasets: [
{ {
backgroundColor: (ctx) => { backgroundColor: (ctx) => {

Loading…
Cancel
Save