Skip to content

Commit 0c5936b

Browse files
Mutugiiidogi
andauthored
manager: smoother report health charting (fixes #9896) (#9897)
Co-authored-by: dogi <dogi@users.noreply.github.com>
1 parent 72fb161 commit 0c5936b

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "planet",
33
"license": "AGPL-3.0",
4-
"version": "0.22.63",
4+
"version": "0.22.64",
55
"myplanet": {
6-
"latest": "v0.54.48",
6+
"latest": "v0.54.54",
77
"min": "v0.52.45"
88
},
99
"scripts": {

src/app/manager-dashboard/reports/reports-health.component.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Component, Input, OnChanges, EventEmitter, Output, ViewChild } from '@angular/core';
2-
import { Chart, ChartConfiguration, LineController } from 'chart.js';
2+
import type { ChartConfiguration } from 'chart.js';
3+
import { loadChart } from '../../shared/chart-utils';
34
import { StateService } from '../../shared/state.service';
45
import { HealthService } from '../../health/health.service';
5-
import { generateWeeksArray, filterByDate, weekDataLabels, scaleLabel } from './reports.utils';
6+
import { generateWeeksArray, filterByDate, weekDataLabels } from './reports.utils';
67
import { ReportsService } from './reports.service';
78
import { millisecondsToDay } from '../../meetups/constants';
89
import { dedupeShelfReduce, styleVariables } from '../../shared/utils';
@@ -14,8 +15,6 @@ import { MatSelect } from '@angular/material/select';
1415
import { MatOption } from '@angular/material/autocomplete';
1516
import { ReportsDetailActivitiesComponent } from './reports-detail-activities.component';
1617

17-
Chart.register(LineController);
18-
1918
@Component({
2019
selector: 'planet-reports-health',
2120
templateUrl: './reports-health.component.html',
@@ -130,7 +129,10 @@ export class ReportsHealthComponent implements OnChanges {
130129
});
131130
}
132131

133-
setChart({ data, chartName }) {
132+
async setChart({ data, chartName }) {
133+
const { Chart } = await loadChart([
134+
'LineController', 'LineElement', 'PointElement', 'CategoryScale', 'LinearScale', 'Title', 'Tooltip'
135+
]);
134136
const updateChart = this.charts.find(chart => chart.canvas.id === chartName);
135137
if (updateChart) {
136138
updateChart.data = data;
@@ -141,6 +143,7 @@ export class ReportsHealthComponent implements OnChanges {
141143
setTimeout(() => this.setChart({ data, chartName }));
142144
return;
143145
}
146+
const axisTitleFont = { size: 12, weight: 'bold' as const };
144147
const chartConfig: ChartConfiguration<'line'> = {
145148
type: 'line',
146149
data,
@@ -153,9 +156,13 @@ export class ReportsHealthComponent implements OnChanges {
153156
scales: {
154157
y: {
155158
type: 'linear',
156-
ticks: { precision: 0 }
159+
ticks: { precision: 0 },
160+
title: { display: true, text: $localize`Diagnoses`, font: axisTitleFont }
157161
},
158-
x: { title: { display: true, text: 'Week of' } }
162+
x: {
163+
type: 'category',
164+
title: { display: true, text: $localize`Week of`, font: axisTitleFont }
165+
}
159166
},
160167
}
161168
};

src/app/manager-dashboard/reports/reports.utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ export const generateWeeksArray = (dateRange: { startDate: Date, endDate: Date }
124124
return weeks;
125125
};
126126

127-
export const scaleLabel = (labelString: string) => ({
128-
display: true, labelString, fontSize: 12, fontStyle: 'bold'
129-
});
130-
131127
export const sortingOptionsMap = {
132128
'logins': [
133129
{ name: $localize`Login Time Ascending`, value: 'loginTimeAsc' },

0 commit comments

Comments
 (0)