From 1f8424455f24f8bdc2394563e771a1df80e30330 Mon Sep 17 00:00:00 2001 From: Tristan Bastian Date: Wed, 21 Aug 2024 21:32:16 +0200 Subject: [PATCH] fix: pie charts in firnware statistics --- angular.json | 8 +++---- .../device-creation-history.component.ts | 7 +++--- .../tenant-creation-history.component.ts | 8 +++---- .../shared/bar-chart/bar-chart.component.ts | 8 +++---- .../firmware-statistics.component.html | 2 +- .../firmware-statistics.component.ts | 21 ++++++++++------ .../pie-chart/pie-chart.component.html | 1 + .../pie-chart/pie-chart.component.ts | 24 +++++++++++-------- 8 files changed, 45 insertions(+), 34 deletions(-) diff --git a/angular.json b/angular.json index 4cf0cd3..e297c4b 100644 --- a/angular.json +++ b/angular.json @@ -77,10 +77,10 @@ "builder": "@c8y/devkit:dev-server", "configurations": { "production": { - "buildTarget": "cumulocity-subtenant-management:build:production" + "buildTarget": "sag-pkg-subtenant-management:build:production" }, "development": { - "buildTarget": "cumulocity-subtenant-management:build:development" + "buildTarget": "sag-pkg-subtenant-management:build:development" } }, "defaultConfiguration": "development" @@ -111,10 +111,10 @@ "builder": "@c8y/devkit:deploy", "configurations": { "production": { - "buildTarget": "cumulocity-subtenant-management:build:production" + "buildTarget": "sag-pkg-subtenant-management:build:production" }, "development": { - "buildTarget": "cumulocity-subtenant-management:build:development" + "buildTarget": "sag-pkg-subtenant-management:build:development" } }, "defaultConfiguration": "production" diff --git a/src/modules/home/device-creation-history/device-creation-history.component.ts b/src/modules/home/device-creation-history/device-creation-history.component.ts index fecd36d..37fb26f 100644 --- a/src/modules/home/device-creation-history/device-creation-history.component.ts +++ b/src/modules/home/device-creation-history/device-creation-history.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; -import { ChartDataset, ChartOptions, Point, ChartType } from 'chart.js'; +import { ChartDataset, ChartOptions, Point, ChartType, Plugin } from 'chart.js'; import { BaseChartDirective } from 'ng2-charts'; -import * as pluginChartZoom from 'chartjs-plugin-zoom'; +import { default as pluginChartZoom } from 'chartjs-plugin-zoom'; import { DeviceDetailsService } from '@services/device-details.service'; import { FakeMicroserviceService } from '@services/fake-microservice.service'; @@ -16,7 +16,6 @@ export class DeviceCreationHistoryComponent implements OnInit { responsive: true, maintainAspectRatio: false, scales: { - x: { type: 'time', @@ -47,7 +46,7 @@ export class DeviceCreationHistoryComponent implements OnInit { }; public readonly lineChartType = 'line' satisfies ChartType; public lineChartLegend = true; - public lineChartPlugins = [ + public lineChartPlugins: Plugin<'line'>[] = [ pluginChartZoom, // { // afterEvent: (chartInstance: BaseChartDirective<'line'>['chart'], chartEvent: any) => { diff --git a/src/modules/home/tenant-creation-history/tenant-creation-history.component.ts b/src/modules/home/tenant-creation-history/tenant-creation-history.component.ts index d45b69f..9fb7b99 100644 --- a/src/modules/home/tenant-creation-history/tenant-creation-history.component.ts +++ b/src/modules/home/tenant-creation-history/tenant-creation-history.component.ts @@ -1,9 +1,9 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { ITenant, TenantStatus } from '@c8y/client'; import { SubtenantDetailsService } from '@services/subtenant-details.service'; -import { ChartDataset, ChartOptions, Point, ChartType } from 'chart.js'; +import { ChartDataset, ChartOptions, Point, ChartType, Plugin } from 'chart.js'; import { BaseChartDirective } from 'ng2-charts'; -import * as pluginChartZoom from 'chartjs-plugin-zoom'; +import { default as pluginChartZoom } from 'chartjs-plugin-zoom'; @Component({ selector: 'ps-tenant-creation-history', @@ -47,9 +47,9 @@ export class TenantCreationHistoryComponent implements OnInit { } } }; - public lineChartType: ChartType = 'line'; + public readonly lineChartType = 'line' satisfies ChartType; public lineChartLegend = true; - public lineChartPlugins = [ + public lineChartPlugins: Plugin<'line'>[] = [ pluginChartZoom, // { // afterEvent: (chartInstance: BaseChartDirective<'line'>['chart'], chartEvent: any) => { diff --git a/src/modules/shared/bar-chart/bar-chart.component.ts b/src/modules/shared/bar-chart/bar-chart.component.ts index 26055a0..0d2a625 100644 --- a/src/modules/shared/bar-chart/bar-chart.component.ts +++ b/src/modules/shared/bar-chart/bar-chart.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnChanges, SimpleChanges, ViewChild } from '@angular/core'; -import { ChartDataset, ChartOptions, ChartType, TimeUnit } from 'chart.js'; +import { ChartDataset, ChartOptions, ChartType, Plugin, TimeUnit } from 'chart.js'; import { BaseChartDirective } from 'ng2-charts'; -import * as pluginDataLabels from 'chartjs-plugin-datalabels'; +import 'chartjs-plugin-datalabels'; @Component({ selector: 'ps-bar-chart', @@ -36,9 +36,9 @@ export class BarChartComponent implements OnChanges { } } }; - public barChartType: ChartType = 'bar'; + public readonly barChartType = 'bar' satisfies ChartType; public barChartLegend = false; - public barChartPlugins = [pluginDataLabels]; + public barChartPlugins: Plugin<'bar'>[] = []; ngOnChanges(changes: SimpleChanges): void { const xAxes: any = this.barChartOptions.scales?.['xAxes'] || {}; diff --git a/src/modules/statistics/firmware-statistics/firmware-statistics.component.html b/src/modules/statistics/firmware-statistics/firmware-statistics.component.html index 6082563..9ef9be9 100644 --- a/src/modules/statistics/firmware-statistics/firmware-statistics.component.html +++ b/src/modules/statistics/firmware-statistics/firmware-statistics.component.html @@ -28,7 +28,7 @@

{{ "No device/firmware combination selected." | translate }}

{{ currentChart.label }}

- +