Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/upgrade chart.js to version 4.2.0 (#1567)
Thomas Kaul436f791fa44f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d3097955ce..20157990df 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).+## Unreleased++### Changed++- Upgraded `chart.js` from version `4.0.1` to `4.2.0`+## 1.233.0 - 2023-02-09### Addeddiff --git a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.tsindex 8adffa0051..dd52fbcfd1 100644--- a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts+++ b/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 {Chart,+ ChartData,LineController,LineElement,LinearScale,@@ -57,7 +58,7 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {@ViewChild('chartCanvas') chartCanvas;- public chart: Chart<any>;+ public chart: Chart<'line'>;public constructor() {Chart.register(@@ -89,14 +90,14 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {}private initialize() {- const data = {+ const data: ChartData<'line'> = {datasets: [{backgroundColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`,borderColor: `rgb(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`,borderWidth: 2,data: this.performanceDataItems.map(({ date, value }) => {- return { x: parseDate(date), y: value };+ return { x: parseDate(date).getTime(), y: value };}),label: $localize`Portfolio`},@@ -105,7 +106,7 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {borderColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`,borderWidth: 2,data: this.benchmarkDataItems.map(({ date, value }) => {- return { x: parseDate(date), y: value };+ return { x: parseDate(date).getTime(), y: value };}),label: $localize`Benchmark`}diff --git a/apps/client/src/app/components/investment-chart/investment-chart.component.ts b/apps/client/src/app/components/investment-chart/investment-chart.component.tsindex 65ecbabb83..6f27bceb4e 100644--- a/apps/client/src/app/components/investment-chart/investment-chart.component.ts+++ b/apps/client/src/app/components/investment-chart/investment-chart.component.ts@@ -29,6 +29,7 @@ import {BarController,BarElement,Chart,+ ChartData,LineController,LineElement,LinearScale,@@ -62,7 +63,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {@ViewChild('chartCanvas') chartCanvas;- public chart: Chart<any>;+ public chart: Chart<'bar' | 'line'>;private investments: InvestmentItem[];private values: LineChartItem[];@@ -142,7 +143,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {});}- const chartData = {+ const chartData: ChartData<'line'> = {labels: this.historicalDataItems.map(({ date }) => {return parseDate(date);}),@@ -153,7 +154,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {borderWidth: this.groupBy ? 0 : 1,data: this.investments.map(({ date, investment }) => {return {- x: parseDate(date),+ x: parseDate(date).getTime(),y: this.isInPercent ? investment * 100 : investment};}),@@ -173,7 +174,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy {borderWidth: 2,data: this.values.map(({ date, value }) => {return {- x: parseDate(date),+ x: parseDate(date).getTime(),y: this.isInPercent ? value * 100 : value};}),diff --git a/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts b/libs/ui/src/lib/fire-calculator/fire-calculator.component.tsindex e4e77095d1..e6cb7d5870 100644--- a/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts+++ b/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts@@ -61,7 +61,7 @@ export class FireCalculatorComponentprincipalInvestmentAmount: new FormControl<number>(undefined),time: new FormControl<number>(undefined)});- public chart: Chart;+ public chart: Chart<'bar'>;public isLoading = true;public projectedTotalAmount: number;diff --git a/libs/ui/src/lib/line-chart/line-chart.component.ts b/libs/ui/src/lib/line-chart/line-chart.component.tsindex 4fdeddbc70..4be8fd12d2 100644--- a/libs/ui/src/lib/line-chart/line-chart.component.ts+++ b/libs/ui/src/lib/line-chart/line-chart.component.ts@@ -66,7 +66,7 @@ export class LineChartComponent implements AfterViewInit, OnChanges, OnDestroy {@ViewChild('chartCanvas') chartCanvas;- public chart: Chart;+ public chart: Chart<'line'>;public isLoading = true;private readonly ANIMATION_DURATION = 1200;diff --git a/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts b/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.tsindex 296776cc9b..3ff0dd417c 100644--- a/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts+++ b/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts@@ -55,7 +55,7 @@ export class PortfolioProportionChartComponent@ViewChild('chartCanvas') chartCanvas: ElementRef<HTMLCanvasElement>;- public chart: Chart;+ public chart: Chart<'pie'>;public isLoading = true;private readonly OTHER_KEY = 'OTHER';diff --git a/package.json b/package.jsonindex 005ccfd4cb..9a9c3e105a 100644--- a/package.json+++ b/package.json@@ -92,9 +92,9 @@"bull": "4.10.2","cache-manager": "3.4.3","cache-manager-redis-store": "2.0.0",- "chart.js": "4.0.1",- "chartjs-adapter-date-fns": "2.0.1",- "chartjs-plugin-annotation": "2.1.0",+ "chart.js": "4.2.0",+ "chartjs-adapter-date-fns": "3.0.0",+ "chartjs-plugin-annotation": "2.1.2","chartjs-plugin-datalabels": "2.2.0","cheerio": "1.0.0-rc.12","class-transformer": "0.3.2",diff --git a/yarn.lock b/yarn.lockindex 89ee494ca2..143191ed10 100644--- a/yarn.lock+++ b/yarn.lock@@ -3511,6 +3511,11 @@"@jridgewell/resolve-uri" "^3.0.3""@jridgewell/sourcemap-codec" "^1.4.10"+"@kurkle/color@^0.3.0":+ version "0.3.1"+ resolved "https://registry.yarnpkg.com/@kurkle/color/-/color-0.3.1.tgz#ef72bc8022ccf77cdd2715097f062ee591ec145c"+ integrity sha512-hW0GwZj06z/ZFUW2Espl7toVDjghJN+EKqyXzPSV8NV89d5BYp5rRMBJoc+aUN0x5OXDMeRQHazejr2Xmqj2tw==+"@leichtgewicht/ip-codec@^2.0.1":version "2.0.4"resolved "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz"@@ -8617,20 +8622,22 @@ chardet@^0.7.0:resolved "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz"integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==- version "4.0.1"- resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-4.0.1.tgz#93d5d50ac222a5b3b6ac7488e82e1553ac031592"- integrity sha512-5/8/9eBivwBZK81mKvmIwTb2Pmw4D/5h1RK9fBWZLLZ8mCJ+kfYNmV9rMrGoa5Hgy2/wVDBMLSUDudul2/9ihA==+ version "4.2.0"+ resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-4.2.0.tgz#dd281b2ce890bff32f3e249cf2972a1e74bc032c"+ integrity sha512-wbtcV+QKeH0F7gQZaCJEIpsNriFheacouJQTVIjITi3eQA8bTlIBoknz0+dgV79aeKLNMAX+nDslIVE/nJ3rzA==+ dependencies:+ "@kurkle/color" "^0.3.0"- version "2.0.1"- resolved "https://registry.yarnpkg.com/chartjs-adapter-date-fns/-/chartjs-adapter-date-fns-2.0.1.tgz#3d007d4985391362fb15c96310fff8376a434bae"- integrity sha512-v3WV9rdnQ05ce3A0ZCjzUekJCAbfm6+3HqSoeY2BIkdMYZoYr/4T+ril1tZyDl869lz6xdNVMXejUFT9YKpw4A==+ version "3.0.0"+ resolved "https://registry.yarnpkg.com/chartjs-adapter-date-fns/-/chartjs-adapter-date-fns-3.0.0.tgz#c25f63c7f317c1f96f9a7c44bd45eeedb8a478e5"+ integrity sha512-Rs3iEB3Q5pJ973J93OBTpnP7qoGwvq3nUnoMdtxO+9aoJof7UFcRbWcIDteXuYd1fgAvct/32T9qaLyLuZVwCg==- version "2.1.0"- resolved "https://registry.yarnpkg.com/chartjs-plugin-annotation/-/chartjs-plugin-annotation-2.1.0.tgz#c43172d26ec8e7e3bc104932d1a1807bf0c46db7"- integrity sha512-wHxP6mBWrgdldAEbHM5nMaMJ3PuunXgiotVh8natosuZsEqpjU0ZeyvMTBwIkKXLSDncb3faLunl4BI89Vmj/g==+ version "2.1.2"+ resolved "https://registry.yarnpkg.com/chartjs-plugin-annotation/-/chartjs-plugin-annotation-2.1.2.tgz#8c307c931fda735a1acf1b606ad0e3fd7d96299b"+ integrity sha512-kmEp2WtpogwnKKnDPO3iO3mVwvVGtmG5BkZVtAEZm5YzJ9CYxojjYEgk7OTrFbJ5vU098b84UeJRe8kRfNcq5g==version "2.2.0"