diff --git a/frontend/cloud-ui/src/app/components/charts/type/chart-type.component.html b/frontend/cloud-ui/src/app/components/charts/type/chart-type.component.html index 18808771..b399093d 100644 --- a/frontend/cloud-ui/src/app/components/charts/type/chart-type.component.html +++ b/frontend/cloud-ui/src/app/components/charts/type/chart-type.component.html @@ -1,12 +1,14 @@ - - +@if (chartOptions) { + + +} diff --git a/frontend/cloud-ui/src/app/components/charts/type/chart-type.component.ts b/frontend/cloud-ui/src/app/components/charts/type/chart-type.component.ts index b877525a..e002f008 100644 --- a/frontend/cloud-ui/src/app/components/charts/type/chart-type.component.ts +++ b/frontend/cloud-ui/src/app/components/charts/type/chart-type.component.ts @@ -10,7 +10,7 @@ import {UserAccountWithRole} from '../../../types/user-account'; imports: [NgApexchartsModule], }) export class ChartTypeComponent implements OnDestroy { - public chartOptions: ApexOptions; + public chartOptions?: ApexOptions; private readonly deploymentTargets = inject(DeploymentTargetsService); private readonly deploymentTargets$ = this.deploymentTargets.list(); @@ -18,48 +18,48 @@ export class ChartTypeComponent implements OnDestroy { private readonly destroyed$ = new Subject(); constructor() { - this.chartOptions = { - series: [], - labels: [], - colors: ['#0db7ed', '#326CE5', '#174c76'], - chart: { - height: 192, - type: 'donut', - sparkline: { - enabled: true, + this.deploymentTargets$.pipe(takeUntil(this.destroyed$)).subscribe((dts) => { + this.chartOptions = { + series: [], + labels: [], + colors: ['#0db7ed', '#326CE5', '#174c76'], + chart: { + height: 192, + type: 'donut', + sparkline: { + enabled: true, + }, }, - }, - stroke: { - curve: 'smooth', - }, - tooltip: { - enabled: false, - }, - legend: { - show: true, - position: 'top', - fontFamily: 'Inter', - labels: { - colors: 'rgb(156, 163, 175)', - useSeriesColors: false, + stroke: { + curve: 'smooth', }, - }, - title: { - text: 'Deployment Managers', - align: 'center', - offsetY: 10, - style: { - color: 'rgb(156, 163, 175)', - fontFamily: 'Poppins', + tooltip: { + enabled: false, }, - }, - plotOptions: { - pie: { - customScale: 0.8, + legend: { + show: true, + position: 'top', + fontFamily: 'Inter', + labels: { + colors: 'rgb(156, 163, 175)', + useSeriesColors: false, + }, }, - }, - }; - this.deploymentTargets$.pipe(takeUntil(this.destroyed$)).subscribe((dts) => { + title: { + text: 'Deployment Managers', + align: 'center', + offsetY: 10, + style: { + color: 'rgb(156, 163, 175)', + fontFamily: 'Poppins', + }, + }, + plotOptions: { + pie: { + customScale: 0.8, + }, + }, + }; const managers: {[key: string]: UserAccountWithRole} = {}; const counts: {[key: string]: number} = {}; for (const dt of dts) { @@ -70,6 +70,7 @@ export class ChartTypeComponent implements OnDestroy { counts[dt.createdBy.id] = counts[dt.createdBy.id] + 1; } } + this.chartOptions.labels = Object.values(managers).map((v) => v.name ?? v.email); this.chartOptions.series = Object.values(counts); });