Skip to content

Commit f912d62

Browse files
committed
refactor(chartjs): update to ChartJS 4.x, types cleanup, use afterRender for SSR
1 parent f31f979 commit f912d62

File tree

7 files changed

+19
-20
lines changed

7 files changed

+19
-20
lines changed

projects/coreui-angular-chartjs/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 creativeLabs Łukasz Holeczek
3+
Copyright (c) 2024 creativeLabs Łukasz Holeczek
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

projects/coreui-angular-chartjs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
```bash
4141
npm install chart.js
42-
npm install @coreui/chartjs@3
42+
npm install @coreui/chartjs@4
4343
npm install @coreui/angular-chartjs
4444
````
4545

@@ -171,4 +171,4 @@ Thanks to all the backers and sponsors! Support this project by [becoming a back
171171
172172
## Copyright and license
173173
174-
Copyright 2023 creativeLabs Łukasz Holeczek. Code released under the [MIT License](https://github.com/coreui/coreui-angular/blob/main/LICENSE). Docs released under [Creative Commons](https://creativecommons.org/licenses/by/3.0/).
174+
Copyright 2024 creativeLabs Łukasz Holeczek. Code released under the [MIT License](https://github.com/coreui/coreui-angular/blob/main/LICENSE). Docs released under [Creative Commons](https://creativecommons.org/licenses/by/3.0/).

projects/coreui-angular-chartjs/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "@coreui/angular-chartjs",
3-
"version": "4.7.16",
3+
"version": "5.0.0-next.23",
44
"description": "Angular wrapper component for Chart.js",
5-
"copyright": "Copyright 2023 creativeLabs Łukasz Holeczek",
5+
"copyright": "Copyright 2024 creativeLabs Łukasz Holeczek",
66
"license": "MIT",
77
"homepage": "https://coreui.io/angular",
88
"author": {
@@ -28,8 +28,8 @@
2828
"@angular/cdk": "^17.0.0",
2929
"@angular/common": "^17.0.0",
3030
"@angular/core": "^17.0.0",
31-
"@coreui/chartjs": "^3.0.0",
32-
"chart.js": "^3.9.1"
31+
"@coreui/chartjs": "^4.0.0-0 || ^4.0.0",
32+
"chart.js": "^4.4.1"
3333
},
3434
"dependencies": {
3535
"lodash-es": "^4.17.21",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './public-api';

projects/coreui-angular-chartjs/src/lib/chartjs.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
role="img"
88
style="display: none;"
99
>
10-
<ng-content></ng-content>
10+
<ng-content />
11+
<!-- <ng-container *ngTemplateOutlet="fallbackContent"/>-->
1112
</canvas>

projects/coreui-angular-chartjs/src/lib/chartjs.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
22

33
import { ChartjsComponent } from './chartjs.component';
4-
import { Chart, ChartData, registerables } from 'chart.js';
4+
import { Chart, registerables } from 'chart.js';
55

66
describe('ChartjsComponent', () => {
77
let component: ChartjsComponent;
@@ -16,7 +16,7 @@ describe('ChartjsComponent', () => {
1616

1717
const labels = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
1818

19-
const data: ChartData = {
19+
const data = {
2020
labels: labels,
2121
datasets: [{
2222
data: [65, 59, 84, 84, 51, 55, 40],

projects/coreui-angular-chartjs/src/lib/chartjs.component.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,8 @@ import {
2222

2323
import merge from 'lodash-es/merge';
2424

25-
import {
26-
Chart as ChartJS,
27-
ChartConfiguration,
28-
ChartData,
29-
ChartOptions,
30-
ChartType,
31-
InteractionItem,
32-
Plugin,
33-
registerables
34-
} from 'chart.js';
25+
import type { ChartConfiguration, ChartData, ChartOptions, ChartType, InteractionItem, Plugin } from 'chart.js';
26+
import { Chart as ChartJS, registerables } from 'chart.js';
3527
import { customTooltips as cuiCustomTooltips } from '@coreui/chartjs';
3628

3729
ChartJS.register(...registerables);
@@ -62,6 +54,11 @@ export class ChartjsComponent implements AfterViewInit, OnDestroy, OnChanges {
6254
*/
6355
@Input() data?: ChartData;
6456

57+
/**
58+
* A fallback when the canvas cannot be rendered. Can be used for accessible chart descriptions.
59+
*/
60+
// @Input() fallbackContent?: TemplateRef<any>;
61+
6562
/**
6663
* Height attribute applied to the rendered canvas.
6764
* @type number | undefined

0 commit comments

Comments
 (0)