|
|
@ -19,7 +19,8 @@ import { primaryColorRgb, secondaryColorRgb } from '@ghostfolio/common/config';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
getBackgroundColor,
|
|
|
|
getBackgroundColor,
|
|
|
|
getDateFormatString,
|
|
|
|
getDateFormatString,
|
|
|
|
getTextColor
|
|
|
|
getTextColor,
|
|
|
|
|
|
|
|
parseDate
|
|
|
|
} from '@ghostfolio/common/helper';
|
|
|
|
} from '@ghostfolio/common/helper';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
LineChartItem,
|
|
|
|
LineChartItem,
|
|
|
@ -56,7 +57,7 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {
|
|
|
|
@ViewChild('chartCanvas') chartCanvas;
|
|
|
|
@ViewChild('chartCanvas') chartCanvas;
|
|
|
|
|
|
|
|
|
|
|
|
public benchmark: UniqueAsset;
|
|
|
|
public benchmark: UniqueAsset;
|
|
|
|
public chart: Chart;
|
|
|
|
public chart: Chart<any>;
|
|
|
|
public isLoading = true;
|
|
|
|
public isLoading = true;
|
|
|
|
|
|
|
|
|
|
|
|
public constructor() {
|
|
|
|
public constructor() {
|
|
|
@ -92,16 +93,13 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {
|
|
|
|
this.isLoading = true;
|
|
|
|
this.isLoading = true;
|
|
|
|
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
const data = {
|
|
|
|
labels: this.performanceDataItems.map(({ date }) => {
|
|
|
|
|
|
|
|
return date;
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
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(({ value }) => {
|
|
|
|
data: this.performanceDataItems.map(({ date, value }) => {
|
|
|
|
return value;
|
|
|
|
return { x: parseDate(date), y: value };
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
label: $localize`Portfolio`
|
|
|
|
label: $localize`Portfolio`
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -109,8 +107,8 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy {
|
|
|
|
backgroundColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`,
|
|
|
|
backgroundColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`,
|
|
|
|
borderColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`,
|
|
|
|
borderColor: `rgb(${secondaryColorRgb.r}, ${secondaryColorRgb.g}, ${secondaryColorRgb.b})`,
|
|
|
|
borderWidth: 2,
|
|
|
|
borderWidth: 2,
|
|
|
|
data: this.benchmarkDataItems.map(({ value }) => {
|
|
|
|
data: this.benchmarkDataItems.map(({ date, value }) => {
|
|
|
|
return value;
|
|
|
|
return { x: parseDate(date), y: value };
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
label: $localize`Benchmark`
|
|
|
|
label: $localize`Benchmark`
|
|
|
|
}
|
|
|
|
}
|
|
|
|