|
|
@ -32,6 +32,7 @@ import { |
|
|
LineController, |
|
|
LineController, |
|
|
LineElement, |
|
|
LineElement, |
|
|
PointElement, |
|
|
PointElement, |
|
|
|
|
|
type ScriptableContext, |
|
|
type ScriptableLineSegmentContext, |
|
|
type ScriptableLineSegmentContext, |
|
|
TimeScale, |
|
|
TimeScale, |
|
|
Tooltip, |
|
|
Tooltip, |
|
|
@ -41,6 +42,7 @@ import 'chartjs-adapter-date-fns'; |
|
|
import { type AnnotationOptions } from 'chartjs-plugin-annotation'; |
|
|
import { type AnnotationOptions } from 'chartjs-plugin-annotation'; |
|
|
import { isFuture } from 'date-fns'; |
|
|
import { isFuture } from 'date-fns'; |
|
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; |
|
|
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; |
|
|
|
|
|
import OpenColor from 'open-color'; |
|
|
|
|
|
|
|
|
import { |
|
|
import { |
|
|
getTimeSeriesTooltipOptions, |
|
|
getTimeSeriesTooltipOptions, |
|
|
@ -48,6 +50,8 @@ import { |
|
|
registerChartConfiguration |
|
|
registerChartConfiguration |
|
|
} from '../chart'; |
|
|
} from '../chart'; |
|
|
|
|
|
|
|
|
|
|
|
const { orange } = OpenColor; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
changeDetection: ChangeDetectionStrategy.OnPush, |
|
|
changeDetection: ChangeDetectionStrategy.OnPush, |
|
|
imports: [NgxSkeletonLoaderModule], |
|
|
imports: [NgxSkeletonLoaderModule], |
|
|
@ -58,6 +62,7 @@ import { |
|
|
export class GfInvestmentChartComponent implements OnChanges, OnDestroy { |
|
|
export class GfInvestmentChartComponent implements OnChanges, OnDestroy { |
|
|
@Input() public benchmarkDataItems: InvestmentItem[] = []; |
|
|
@Input() public benchmarkDataItems: InvestmentItem[] = []; |
|
|
@Input() public benchmarkDataLabel = ''; |
|
|
@Input() public benchmarkDataLabel = ''; |
|
|
|
|
|
@Input() public colorizeSign = false; |
|
|
@Input() public colorScheme?: ColorScheme; |
|
|
@Input() public colorScheme?: ColorScheme; |
|
|
@Input() public currency?: string; |
|
|
@Input() public currency?: string; |
|
|
@Input() public groupBy?: GroupBy; |
|
|
@Input() public groupBy?: GroupBy; |
|
|
@ -133,7 +138,17 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy { |
|
|
}), |
|
|
}), |
|
|
datasets: [ |
|
|
datasets: [ |
|
|
{ |
|
|
{ |
|
|
backgroundColor: `rgb(${benchmarkColorRgb.r}, ${benchmarkColorRgb.g}, ${benchmarkColorRgb.b})`, |
|
|
backgroundColor: (context: ScriptableContext<'bar' | 'line'>) => { |
|
|
|
|
|
if ( |
|
|
|
|
|
(context.parsed?.y ?? 0) < 0 && |
|
|
|
|
|
isBarChart && |
|
|
|
|
|
this.colorizeSign |
|
|
|
|
|
) { |
|
|
|
|
|
return orange[5]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return `rgb(${benchmarkColorRgb.r}, ${benchmarkColorRgb.g}, ${benchmarkColorRgb.b})`; |
|
|
|
|
|
}, |
|
|
borderColor: `rgb(${benchmarkColorRgb.r}, ${benchmarkColorRgb.g}, ${benchmarkColorRgb.b})`, |
|
|
borderColor: `rgb(${benchmarkColorRgb.r}, ${benchmarkColorRgb.g}, ${benchmarkColorRgb.b})`, |
|
|
borderWidth: isBarChart ? 0 : 1, |
|
|
borderWidth: isBarChart ? 0 : 1, |
|
|
data: this.investments.map(({ date, investment }) => { |
|
|
data: this.investments.map(({ date, investment }) => { |
|
|
|