diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d55dffd..febad474 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 + +- Cleaned up the analysis page with an unused chart module + ## 1.14.0 - 09.06.2021 ### Added diff --git a/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.component.html b/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.component.html deleted file mode 100644 index fd1e8e98..00000000 --- a/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.component.html +++ /dev/null @@ -1,12 +0,0 @@ - - diff --git a/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.component.scss b/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.component.scss deleted file mode 100644 index 5d4e87f3..00000000 --- a/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -:host { - display: block; -} diff --git a/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.component.ts b/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.component.ts deleted file mode 100644 index 42e36e22..00000000 --- a/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.component.ts +++ /dev/null @@ -1,158 +0,0 @@ -// import 'chartjs-chart-timeline'; - -import { - ChangeDetectionStrategy, - Component, - Input, - OnChanges, - OnInit -} from '@angular/core'; -import { PortfolioItem } from '@ghostfolio/common/interfaces'; -import { endOfDay, parseISO, startOfDay } from 'date-fns'; - -@Component({ - selector: 'gf-portfolio-positions-chart', - changeDetection: ChangeDetectionStrategy.OnPush, - templateUrl: './portfolio-positions-chart.component.html', - styleUrls: ['./portfolio-positions-chart.component.scss'] -}) -export class PortfolioPositionsChartComponent implements OnChanges, OnInit { - @Input() portfolioItems: PortfolioItem[]; - - // @ViewChild('timelineCanvas') timeline; - - public isLoading = true; - - public constructor() {} - - public ngOnInit() {} - - public ngOnChanges() { - if (this.portfolioItems) { - this.initialize(); - } - } - - private initialize() { - this.isLoading = true; - - let datasets = []; - const fromToPosition = {}; - - this.portfolioItems.forEach((positionsByDay) => { - Object.keys(positionsByDay.positions).forEach((symbol) => { - if (fromToPosition[symbol]) { - fromToPosition[symbol].push({ - date: positionsByDay.date, - quantity: positionsByDay.positions[symbol].quantity - }); - } else { - fromToPosition[symbol] = [ - { - date: positionsByDay.date, - quantity: positionsByDay.positions[symbol].quantity - } - ]; - } - }); - }); - - Object.keys(fromToPosition).forEach((symbol) => { - let currentDate = null; - let currentQuantity = null; - let data = []; - let hasStock = false; - - fromToPosition[symbol].forEach((x, index) => { - if (x.quantity > 0 && index === 0) { - currentDate = x.date; - hasStock = true; - } - - if (x.quantity === 0 || index === fromToPosition[symbol].length - 1) { - if (hasStock) { - data.push([ - startOfDay(parseISO(currentDate)), - endOfDay(parseISO(x.date)), - currentQuantity - ]); - hasStock = false; - } else { - // Do nothing - } - } else { - if (hasStock) { - // Do nothing - } else { - currentDate = x.date; - hasStock = true; - } - } - - currentQuantity = x.quantity; - }); - - if (data.length === 0) { - // Fill data for today - data.push([ - startOfDay(new Date()), - endOfDay(new Date()), - currentQuantity - ]); - } - - datasets.push({ data, symbol }); - }); - - // Sort by date - datasets = datasets.sort((a: any, b: any) => { - return a.data[0][0].getTime() - b.data[0][0].getTime(); - }); - - /*new Chart(this.timeline.nativeElement, { - type: 'timeline', - options: { - elements: { - colorFunction: (text, data, dataset, index) => { - return `rgba(${primaryColorRgb.r}, ${primaryColorRgb.g}, ${primaryColorRgb.b})`; - }, - showText: false, - textPadding: 4 - }, - maintainAspectRatio: true, - responsive: true, - scales: { - xAxes: [ - { - gridLines: { - display: false - }, - position: 'top', - time: { - unit: 'year' - } - } - ], - yAxes: [ - { - gridLines: { - display: false - }, - ticks: { - display: false - } - } - ] - } - }, - data: { - datasets, - labels: datasets.map((dataset) => { - return dataset.symbol; - }) - } - });*/ - - this.isLoading = false; - } -} diff --git a/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.module.ts b/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.module.ts deleted file mode 100644 index c27f4c1d..00000000 --- a/apps/client/src/app/components/portfolio-positions-chart/portfolio-positions-chart.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; - -import { PortfolioPositionsChartComponent } from './portfolio-positions-chart.component'; - -@NgModule({ - declarations: [PortfolioPositionsChartComponent], - exports: [PortfolioPositionsChartComponent], - imports: [CommonModule, NgxSkeletonLoaderModule], - providers: [] -}) -export class PortfolioPositionsChartModule {} diff --git a/apps/client/src/app/pages/tools/analysis/analysis-page.html b/apps/client/src/app/pages/tools/analysis/analysis-page.html index 8aa1783a..c8267869 100644 --- a/apps/client/src/app/pages/tools/analysis/analysis-page.html +++ b/apps/client/src/app/pages/tools/analysis/analysis-page.html @@ -191,26 +191,6 @@ -
-
- - -
-
- -
-
- You can find more charts on your desktop: - Ghostfol.io -
-
-
-
-
-
@@ -241,9 +221,6 @@ > - diff --git a/apps/client/src/app/pages/tools/analysis/analysis-page.module.ts b/apps/client/src/app/pages/tools/analysis/analysis-page.module.ts index 3c714a32..d8974b3c 100644 --- a/apps/client/src/app/pages/tools/analysis/analysis-page.module.ts +++ b/apps/client/src/app/pages/tools/analysis/analysis-page.module.ts @@ -2,7 +2,6 @@ import { CommonModule } from '@angular/common'; import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; import { MatCardModule } from '@angular/material/card'; import { GfInvestmentChartModule } from '@ghostfolio/client/components/investment-chart/investment-chart.module'; -import { PortfolioPositionsChartModule } from '@ghostfolio/client/components/portfolio-positions-chart/portfolio-positions-chart.module'; import { PortfolioProportionChartModule } from '@ghostfolio/client/components/portfolio-proportion-chart/portfolio-proportion-chart.module'; import { GfPositionsTableModule } from '@ghostfolio/client/components/positions-table/positions-table.module'; import { GfToggleModule } from '@ghostfolio/client/components/toggle/toggle.module'; @@ -22,7 +21,6 @@ import { AnalysisPageComponent } from './analysis-page.component'; GfToggleModule, GfWorldMapChartModule, MatCardModule, - PortfolioPositionsChartModule, PortfolioProportionChartModule ], providers: [], diff --git a/package.json b/package.json index b632c097..50615c84 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,6 @@ "cache-manager-redis-store": "2.0.0", "chart.js": "3.2.1", "chartjs-adapter-date-fns": "1.1.0-beta.1", - "chartjs-chart-timeline": "0.4.0", "cheerio": "1.0.0-rc.6", "class-transformer": "0.3.2", "class-validator": "0.13.1", diff --git a/yarn.lock b/yarn.lock index 42a354e5..8ae8527a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4081,11 +4081,6 @@ chartjs-adapter-date-fns@1.1.0-beta.1: resolved "https://registry.yarnpkg.com/chartjs-adapter-date-fns/-/chartjs-adapter-date-fns-1.1.0-beta.1.tgz#5502dbfe33ff62af44ce6a05df086d1be773469a" integrity sha512-VNhuZ86kXKOwh61CyRLP7hoFqAR7+gjnrtf7KYLt/Wfh3jIQs14l1h+nagtQoFaabIYIo6UD5/jJb2/J6zOPcw== -chartjs-chart-timeline@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/chartjs-chart-timeline/-/chartjs-chart-timeline-0.4.0.tgz#cbd25dc5ddb5c2b34289f8dd7a2a627d71e251e8" - integrity sha512-a3iOFgMUXgEK9zyDFXlL7cfhO6z4DkeuGqok1xnNVNg12ciSt/k1jDBFk8JKN+sVNZfoqeGAFBT9zvb++iEWnA== - check-more-types@^2.24.0: version "2.24.0" resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-2.24.0.tgz#1420ffb10fd444dcfc79b43891bbfffd32a84600"