Skip to content

Commit 1c56b41

Browse files
committed
feat: Add Angular Material theme colors and Highcharts theme configuration
- Generated a new SCSS file for Angular Material theme colors, defining primary, secondary, tertiary, neutral, neutral-variant, and error color palettes. - Implemented a comprehensive Highcharts theme configuration, including tooltip formatting, axis settings, chart styles, legend customization, and exporting options. - Ensured the theme utilizes CSS variables for consistent styling across the application.
1 parent 2eb9cf4 commit 1c56b41

File tree

8 files changed

+1337
-105
lines changed

8 files changed

+1337
-105
lines changed
File renamed without changes.

src/app/app.component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { ThemingService } from './theme.service';
55
import { MatIconRegistry } from '@angular/material/icon';
66
import { DomSanitizer } from '@angular/platform-browser';
77
import { UsageReportService } from './usage-report.service';
8-
// import '../highcharts.theme';
9-
108
ExportingModule(Highcharts);
9+
import '../highcharts.github.theme';
1110

1211
const GITHUB_ICON = `<svg width="24px" height="24px" viewBox="1 0 100 100" xmlns="http://www.w3.org/2000/svg">
1312
<path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"/>
@@ -249,7 +248,7 @@ export class AppComponent implements OnInit {
249248
}
250249
};
251250
}
252-
Highcharts.setOptions(this.options);
251+
// Highcharts.setOptions(this.options);
253252
}
254253
)
255254
this.usageReportService.getValueType().subscribe(valueType => {
@@ -260,7 +259,7 @@ export class AppComponent implements OnInit {
260259
pointFormat: `<b>{series.name}</b><br>${valueType === 'cost' ? '${point.y:.2f}' : '{point.y} mins'}`,
261260
}
262261
}
263-
Highcharts.setOptions(this.options);
262+
// Highcharts.setOptions(this.options);
264263
});
265264
}
266265
}

src/app/components/usage/actions/charts/chart-bar-top-time/chart-bar-top-time.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class ChartBarTopTimeComponent implements OnChanges {
2929
},
3030
xAxis: {
3131
title: {
32-
text: 'Repository'
32+
3333
}
3434
},
3535
series: [{
@@ -88,6 +88,9 @@ export class ChartBarTopTimeComponent implements OnChanges {
8888
format: this.currency === 'cost' ? '${value}' : '{value}',
8989
}
9090
};
91+
this.options.tooltip = {
92+
format: `{point.name}</b><br>${this.currency === 'cost' ? '$<b>{point.y:.2f}</b>' : '<b>{point.y}</b> mins'}`,
93+
};
9194
this.updateFromInput = true;
9295
}
9396
}

src/app/components/usage/actions/charts/chart-line-usage-daily/chart-line-usage-daily.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,15 @@ export class ChartLineUsageDailyComponent implements OnChanges {
168168
text: this.currency === 'minutes' ? 'Minutes (min)' : 'Cost (USD)'
169169
},
170170
labels: {
171-
format: this.currency === 'cost' ? '${value}' : '{value}',
171+
format: this.currency === 'cost' ? '${value:,.2f}' : '{value}',
172172
}
173173
};
174174
this.options.title = {
175175
text: `Actions ${this.currency === 'cost' ? 'Cost' : 'Usage'} ${this.timeType.toUpperCase()}`
176176
};
177+
this.options.tooltip = {
178+
format: `<b>{series.name}</b><br/>{point.x:%Y-%m-%d}<br>${this.currency === 'cost' ? '${point.y:,.2f}' : '{point.y} mins'}`,
179+
}
177180
this.updateFromInput = true;
178181
}
179182

src/app/components/usage/actions/charts/chart-pie-user/chart-pie-user.component.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,33 @@ export class ChartPieUserComponent implements OnChanges {
4343

4444
ngOnChanges() {
4545
this.data = this.data.filter((line) => line.unitType === 'minutes');
46-
this.options.series = [{
47-
type: 'pie',
48-
name: 'Usage',
49-
data: this.data.reduce((acc, line) => {
46+
47+
const aggregatedData = this.data.reduce((acc, line) => {
5048
const index = acc.findIndex((item) => item[0] === line.username);
5149
if (index === -1) {
5250
acc.push([line.username, line.value]);
5351
} else {
5452
acc[index][1] += line.value;
5553
}
5654
return acc;
57-
}, [] as [string, number][]).sort((a, b) => b[1] - a[1])
55+
}, [] as [string, number][])
56+
.sort((a, b) => b[1] - a[1]);
57+
58+
// Take top 20 and group the rest as "Other"
59+
const topNo = 29;
60+
const topX = aggregatedData.slice(0, topNo);
61+
const remaining = aggregatedData.slice(topNo);
62+
63+
const data = [...topX];
64+
if (remaining.length > 0) {
65+
const otherTotal = remaining.reduce((sum, item) => sum + item[1], 0);
66+
data.push(['Other', otherTotal]);
67+
}
68+
69+
this.options.series = [{
70+
type: 'pie',
71+
name: 'Usage',
72+
data
5873
}];
5974
this.options.title = {
6075
text: `${this.currency === 'minutes' ? 'Usage' : 'Cost'} by username`

0 commit comments

Comments
 (0)