Browse Source

Add line breaks

pull/6277/head
Thomas Kaul 6 days ago
parent
commit
a199445e0c
  1. 1
      apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts
  2. 6
      libs/common/src/lib/chart-helper.ts
  3. 1
      libs/ui/src/lib/line-chart/line-chart.component.ts
  4. 4
      libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts
  5. 1
      libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

1
apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts

@ -160,6 +160,7 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy {
this.chart.options.plugins ??= {}; this.chart.options.plugins ??= {};
this.chart.options.plugins.tooltip = this.chart.options.plugins.tooltip =
this.getTooltipPluginConfiguration(); this.getTooltipPluginConfiguration();
this.chart.update(); this.chart.update();
} else { } else {
this.chart = new Chart(this.chartCanvas.nativeElement, { this.chart = new Chart(this.chartCanvas.nativeElement, {

6
libs/common/src/lib/chart-helper.ts

@ -58,11 +58,13 @@ export function getTooltipOptions<T extends ChartType>({
callbacks: { callbacks: {
label: (context) => { label: (context) => {
let label = (context.dataset as ControllerDatasetOptions).label ?? ''; let label = (context.dataset as ControllerDatasetOptions).label ?? '';
if (label) { if (label) {
label += ': '; label += ': ';
} }
const yPoint = (context.parsed as Point).y; const yPoint = (context.parsed as Point).y;
if (yPoint !== null) { if (yPoint !== null) {
if (currency) { if (currency) {
label += `${yPoint.toLocaleString(locale, { label += `${yPoint.toLocaleString(locale, {
@ -75,10 +77,12 @@ export function getTooltipOptions<T extends ChartType>({
label += yPoint.toFixed(2); label += yPoint.toFixed(2);
} }
} }
return label; return label;
}, },
title: (contexts) => { title: (contexts) => {
const xPoint = (contexts[0].parsed as Point).x; const xPoint = (contexts[0].parsed as Point).x;
if (groupBy && xPoint !== null) { if (groupBy && xPoint !== null) {
return formatGroupedDate({ groupBy, date: xPoint }); return formatGroupedDate({ groupBy, date: xPoint });
} }
@ -105,6 +109,7 @@ export function getTooltipPositionerMapTop(
if (!position || !chart?.chartArea) { if (!position || !chart?.chartArea) {
return false; return false;
} }
return { return {
x: position.x, x: position.x,
y: chart.chartArea.top y: chart.chartArea.top
@ -132,6 +137,7 @@ export function getVerticalHoverLinePlugin<T extends 'line' | 'bar'>(
const xValue = active[0].element.x; const xValue = active[0].element.x;
const context = chartCanvas.nativeElement.getContext('2d'); const context = chartCanvas.nativeElement.getContext('2d');
if (context) { if (context) {
context.lineWidth = width; context.lineWidth = width;
context.strokeStyle = color; context.strokeStyle = color;

1
libs/ui/src/lib/line-chart/line-chart.component.ts

@ -187,6 +187,7 @@ export class GfLineChartComponent
this.chart.options.animations = this.isAnimated this.chart.options.animations = this.isAnimated
? animations ? animations
: undefined; : undefined;
this.chart.update(); this.chart.update();
} else { } else {
this.chart = new Chart(this.chartCanvas.nativeElement, { this.chart = new Chart(this.chartCanvas.nativeElement, {

4
libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts

@ -340,6 +340,7 @@ export class GfPortfolioProportionChartComponent
this.chart.options.plugins ??= {}; this.chart.options.plugins ??= {};
this.chart.options.plugins.tooltip = this.chart.options.plugins.tooltip =
this.getTooltipPluginConfiguration(data); this.getTooltipPluginConfiguration(data);
this.chart.update(); this.chart.update();
} else { } else {
this.chart = new Chart<'doughnut'>(this.chartCanvas.nativeElement, { this.chart = new Chart<'doughnut'>(this.chartCanvas.nativeElement, {
@ -440,6 +441,7 @@ export class GfPortfolioProportionChartComponent
const labelIndex = const labelIndex =
(data.datasets[context.datasetIndex - 1]?.data?.length ?? 0) + (data.datasets[context.datasetIndex - 1]?.data?.length ?? 0) +
context.dataIndex; context.dataIndex;
let symbol = let symbol =
(context.chart.data.labels?.[labelIndex] as string) ?? ''; (context.chart.data.labels?.[labelIndex] as string) ?? '';
@ -452,6 +454,7 @@ export class GfPortfolioProportionChartComponent
const name = translate(this.data[symbol]?.name); const name = translate(this.data[symbol]?.name);
let sum = 0; let sum = 0;
for (const item of context.dataset.data) { for (const item of context.dataset.data) {
sum += item; sum += item;
} }
@ -464,6 +467,7 @@ export class GfPortfolioProportionChartComponent
return [`${name ?? symbol}`, `${percentage.toFixed(2)}%`]; return [`${name ?? symbol}`, `${percentage.toFixed(2)}%`];
} else { } else {
const value = context.raw as number; const value = context.raw as number;
return [ return [
`${name ?? symbol}`, `${name ?? symbol}`,
`${value.toLocaleString(this.locale, { `${value.toLocaleString(this.locale, {

1
libs/ui/src/lib/treemap-chart/treemap-chart.component.ts

@ -302,6 +302,7 @@ export class GfTreemapChartComponent
this.chart.options.plugins ??= {}; this.chart.options.plugins ??= {};
this.chart.options.plugins.tooltip = this.chart.options.plugins.tooltip =
this.getTooltipPluginConfiguration(); this.getTooltipPluginConfiguration();
this.chart.update(); this.chart.update();
} else { } else {
this.chart = new Chart<'treemap'>(this.chartCanvas.nativeElement, { this.chart = new Chart<'treemap'>(this.chartCanvas.nativeElement, {

Loading…
Cancel
Save