Feature/support case insensitive names in portfolio proportion chart (#2004)

* Sum up case insensitive names

* Update changelog
This commit is contained in:
Thomas Kaul 2023-05-26 20:41:33 +02:00 committed by GitHub
parent 1f393e78f6
commit b3baeb8a5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 23 deletions

View File

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Decreased the density of the `@angular/material` tables - Decreased the density of the `@angular/material` tables
- Improved the portfolio proportion chart component by supporting case insensitive names
- Improved the breadcrumb navigation style in the blog post pages for mobile - Improved the breadcrumb navigation style in the blog post pages for mobile
- Improved the error handling in the delete user endpoint - Improved the error handling in the delete user endpoint
- Improved the style of the _Changelog & License_ button on the about page - Improved the style of the _Changelog & License_ button on the about page

View File

@ -100,38 +100,42 @@ export class PortfolioProportionChartComponent
}; };
Object.keys(this.positions).forEach((symbol) => { Object.keys(this.positions).forEach((symbol) => {
if (this.positions[symbol][this.keys[0]]) { if (this.positions[symbol][this.keys[0]].toUpperCase()) {
if (chartData[this.positions[symbol][this.keys[0]]]) { if (chartData[this.positions[symbol][this.keys[0]].toUpperCase()]) {
chartData[this.positions[symbol][this.keys[0]]].value = chartData[ chartData[this.positions[symbol][this.keys[0]].toUpperCase()].value =
this.positions[symbol][this.keys[0]] chartData[
].value.plus(this.positions[symbol].value); this.positions[symbol][this.keys[0]].toUpperCase()
].value.plus(this.positions[symbol].value);
if ( if (
chartData[this.positions[symbol][this.keys[0]]].subCategory[ chartData[this.positions[symbol][this.keys[0]].toUpperCase()]
this.positions[symbol][this.keys[1]] .subCategory[this.positions[symbol][this.keys[1]]]
]
) { ) {
chartData[this.positions[symbol][this.keys[0]]].subCategory[ chartData[
this.positions[symbol][this.keys[1]] this.positions[symbol][this.keys[0]].toUpperCase()
].value = chartData[ ].subCategory[this.positions[symbol][this.keys[1]]].value =
this.positions[symbol][this.keys[0]] chartData[
].subCategory[this.positions[symbol][this.keys[1]]].value.plus( this.positions[symbol][this.keys[0]].toUpperCase()
this.positions[symbol].value ].subCategory[this.positions[symbol][this.keys[1]]].value.plus(
); this.positions[symbol].value
);
} else { } else {
chartData[this.positions[symbol][this.keys[0]]].subCategory[ chartData[
this.positions[symbol][this.keys[1]] ?? UNKNOWN_KEY this.positions[symbol][this.keys[0]].toUpperCase()
] = { value: new Big(this.positions[symbol].value) }; ].subCategory[this.positions[symbol][this.keys[1]] ?? UNKNOWN_KEY] =
{ value: new Big(this.positions[symbol].value) };
} }
} else { } else {
chartData[this.positions[symbol][this.keys[0]]] = { chartData[this.positions[symbol][this.keys[0]].toUpperCase()] = {
name: this.positions[symbol].name, name: this.positions[symbol][this.keys[0]],
subCategory: {}, subCategory: {},
value: new Big(this.positions[symbol].value ?? 0) value: new Big(this.positions[symbol].value ?? 0)
}; };
if (this.positions[symbol][this.keys[1]]) { if (this.positions[symbol][this.keys[1]]) {
chartData[this.positions[symbol][this.keys[0]]].subCategory = { chartData[
this.positions[symbol][this.keys[0]].toUpperCase()
].subCategory = {
[this.positions[symbol][this.keys[1]]]: { [this.positions[symbol][this.keys[1]]]: {
value: new Big(this.positions[symbol].value) value: new Big(this.positions[symbol].value)
} }
@ -232,8 +236,8 @@ export class PortfolioProportionChartComponent
} }
]; ];
let labels = chartDataSorted.map(([label]) => { let labels = chartDataSorted.map(([symbol, { name }]) => {
return label; return name;
}); });
if (this.keys[1]) { if (this.keys[1]) {