Browse Source

Fix type issue

pull/1567/head
Thomas 3 years ago
parent
commit
e0cad5a33a
  1. 7
      apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts
  2. 7
      apps/client/src/app/components/investment-chart/investment-chart.component.ts

7
apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts

@ -27,6 +27,7 @@ import { ColorScheme } from '@ghostfolio/common/types';
import { SymbolProfile } from '@prisma/client'; import { SymbolProfile } from '@prisma/client';
import { import {
Chart, Chart,
ChartData,
LineController, LineController,
LineElement, LineElement,
LinearScale, LinearScale,
@ -89,14 +90,14 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {
} }
private initialize() { private initialize() {
const data = { const data: ChartData<'line'> = {
datasets: [ datasets: [
{ {
backgroundColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`, backgroundColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`,
borderColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`, borderColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`,
borderWidth: 2, borderWidth: 2,
data: this.performanceDataItems.map(({ date, value }) => { data: this.performanceDataItems.map(({ date, value }) => {
return { x: parseDate(date), y: value }; return { x: parseDate(date).getTime(), y: value };
}), }),
label: $localize`Portfolio` label: $localize`Portfolio`
}, },
@ -105,7 +106,7 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {
borderColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`, borderColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`,
borderWidth: 2, borderWidth: 2,
data: this.benchmarkDataItems.map(({ date, value }) => { data: this.benchmarkDataItems.map(({ date, value }) => {
return { x: parseDate(date), y: value }; return { x: parseDate(date).getTime(), y: value };
}), }),
label: $localize`Benchmark` label: $localize`Benchmark`
} }

7
apps/client/src/app/components/investment-chart/investment-chart.component.ts

@ -29,6 +29,7 @@ import {
BarController, BarController,
BarElement, BarElement,
Chart, Chart,
ChartData,
LineController, LineController,
LineElement, LineElement,
LinearScale, LinearScale,
@ -142,7 +143,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {
}); });
} }
const chartData = { const chartData: ChartData<'line'> = {
labels: this.historicalDataItems.map(({ date }) => { labels: this.historicalDataItems.map(({ date }) => {
return parseDate(date); return parseDate(date);
}), }),
@ -153,7 +154,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {
borderWidth: this.groupBy ? 0 : 1, borderWidth: this.groupBy ? 0 : 1,
data: this.investments.map(({ date, investment }) => { data: this.investments.map(({ date, investment }) => {
return { return {
x: parseDate(date), x: parseDate(date).getTime(),
y: this.isInPercent ? investment * 100 : investment y: this.isInPercent ? investment * 100 : investment
}; };
}), }),
@ -173,7 +174,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {
borderWidth: 2, borderWidth: 2,
data: this.values.map(({ date, value }) => { data: this.values.map(({ date, value }) => {
return { return {
x: parseDate(date), x: parseDate(date).getTime(),
y: this.isInPercent ? value * 100 : value y: this.isInPercent ? value * 100 : value
}; };
}), }),

Loading…
Cancel
Save