Skip to content

Commit d49d3d3

Browse files
puikinshclaude
andcommitted
feat(charts): replace ApexCharts with Chart.js
ApexCharts moved to its own commercial licence in 5.2.0. Every demo chart (Dashboard v1/v2/v3 and the charts showcase) is rebuilt on Chart.js 4.5.1 (MIT), loaded from jsDelivr with SRI on the charted pages only, with one shared theme preset (_chartjs.astro) that reads AdminLTE's CSS variables and follows data-bs-theme and dir live. charts/apexcharts.html becomes a redirect to charts/chartjs.html; docs, README and dist are updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 12b4b06 commit d49d3d3

105 files changed

Lines changed: 4030 additions & 6252 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- **The demo charts are drawn with Chart.js (MIT) instead of ApexCharts.** From 5.2.0 ApexCharts is published under its own commercial "ApexCharts License" rather than MIT, and a template that thousands of projects copy into their products cannot carry that on to them. Every chart on Dashboard v1, v2 and v3 and on the charts showcase is rebuilt on Chart.js 4.5.1 with the same data, colours and sizes: area and line charts (gradient fills), grouped columns, doughnuts, the radial bar (concentric doughnut rings with the average in the middle), the mixed bar-and-line chart with two value axes, and the dashboard sparklines. Chart.js is loaded from jsDelivr with an SRI hash, only on the pages that draw charts, exactly as ApexCharts was — the `admin-lte` npm package has never depended on a chart library and still does not. Gzipped chart JavaScript per charted page drops from 131.5 kB (ApexCharts 3.37.1 JS + CSS) to 72.8 kB (Chart.js 4.5.1 plus the 2.3 kB inline theme preset below).
13+
14+
The showcase page is now `charts/chartjs.html` and the sidebar entry reads "Chart.js". `charts/apexcharts.html` stays as a redirect so existing links keep working.
15+
16+
- **One chart theme preset, following the colour mode live.** The charted pages include a short preset (`src/html/components/_chartjs.astro`) that sets `Chart.defaults` from AdminLTE's CSS variables — body font, secondary text for ticks, 8% gridlines with no vertical grid on category axes, rounded bars, a tooltip and legend styled like a card — and restyles every chart on the page when `<html data-bs-theme>` changes (the ColorMode toggle, the OS in auto mode, or your own code) or when the web font finishes loading. Under `<html dir="rtl">` legends and tooltips are laid out right-to-left. The ApexCharts colour-mode helper that every demo page carried in its shared scripts (#6105) is gone with it, so the 85 pages without charts are 1.6 kB lighter too. The [dark-mode charts recipe](https://adminlte.io/themes/v4/docs/recipes.html#charts-that-follow-dark-mode), the Recommended Integrations, Migration and RTL docs are updated to match.
17+
18+
One Chart.js detail worth knowing if you adapt the preset: Chart.js copies the scale defaults into each chart's config when the chart is created, so changing `Chart.defaults` and calling `chart.update()` leaves existing axes in the old colours. The preset drops those copied colours before it updates; see the comment in the component.
19+
1020
### Fixed
1121

1222
- **The brand logo sat 4px left of centre in the collapsed mini sidebar.** `.brand-text` keeps its base `margin-left: .5rem` while `.sidebar-mini.sidebar-collapse` shrinks it to `max-width: 0`, so 8px of margin on a zero-width element pushed the logo off the rail's centre line. The margin is now cleared in that state — the hover rule that expands the rail already re-declared `margin-left: .5rem`, which is what the collapsed state should have mirrored all along (#6114, by @dfsmania).

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ AdminLTE is an open source project by [AdminLTE.io](https://adminlte.io) license
292292
[MIT](https://opensource.org/licenses/MIT). AdminLTE.io reserves the right to change
293293
the license of future releases.
294294

295+
The charts on the demo pages are drawn with [Chart.js](https://www.chartjs.org/) (MIT),
296+
loaded from a CDN on the pages that use it — it is not a dependency of the `admin-lte` package.
297+
295298
## Image credits
296299

297300
[Pixeden](http://www.pixeden.com/psd-web-elements/flat-responsive-showcase-psd),

‎dist/UI/colors.html‎

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,9 +1050,9 @@
10501050
</a>
10511051
<ul class="nav nav-treeview">
10521052
<li class="nav-item">
1053-
<a href="../charts/apexcharts.html" class="nav-link">
1053+
<a href="../charts/chartjs.html" class="nav-link">
10541054
<i class="nav-icon bi bi-circle"></i>
1055-
<p>ApexCharts</p>
1055+
<p>Chart.js</p>
10561056
</a>
10571057
</li>
10581058
</ul>
@@ -6327,38 +6327,6 @@ <h5 class="mb-3" data-astro-cid-ghactkgv>Check a brand colour</h5>
63276327
});
63286328
</script>
63296329
<!--end::OverlayScrollbars Configure-->
6330-
<!--begin::Charts follow the colour mode-->
6331-
<script>
6332-
// ApexCharts draws light-theme tooltips and axis text unless told otherwise,
6333-
// which is unreadable in dark mode (#6105). Give it the page's colour mode as
6334-
// a global default before any chart is created — this runs before the chart
6335-
// pages' own scripts — and keep every chart that has a `chart.id` in step
6336-
// when the mode changes (ColorMode, the OS in auto mode, or your own code).
6337-
(() => {
6338-
'use strict';
6339-
const mode = () =>
6340-
document.documentElement.getAttribute('data-bs-theme') === 'dark' ? 'dark' : 'light';
6341-
// `Apex` is ApexCharts' global-options object; it must exist before the library loads.
6342-
// theme.mode also sets a dark chart background — keep the card's instead.
6343-
// eslint-disable-next-line unicorn/no-global-object-property-assignment
6344-
globalThis.Apex ||= {};
6345-
const apex = globalThis.Apex;
6346-
apex.theme = { mode: mode() };
6347-
apex.chart = Object.assign(apex.chart || {}, { background: 'transparent' });
6348-
new MutationObserver(() => {
6349-
const next = mode();
6350-
apex.theme = { mode: next };
6351-
const instances = apex._chartInstances || [];
6352-
for (const { chart } of instances) {
6353-
chart.updateOptions({ theme: { mode: next } }, false, false);
6354-
}
6355-
}).observe(document.documentElement, {
6356-
attributes: true,
6357-
attributeFilter: ['data-bs-theme'],
6358-
});
6359-
})();
6360-
</script>
6361-
<!--end::Charts follow the colour mode-->
63626330

63636331
<!--begin::Color Mode Toggle-->
63646332
<!-- The light/dark/auto switcher ships in adminlte.js as the ColorMode

‎dist/UI/general.html‎

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@
818818
</a>
819819
<ul class="nav nav-treeview">
820820
<li class="nav-item">
821-
<a href="../charts/apexcharts.html" class="nav-link">
821+
<a href="../charts/chartjs.html" class="nav-link">
822822
<i class="nav-icon bi bi-circle"></i>
823-
<p>ApexCharts</p>
823+
<p>Chart.js</p>
824824
</a>
825825
</li>
826826
</ul>
@@ -2834,38 +2834,6 @@ <h5 class="card-title placeholder-glow">
28342834
});
28352835
</script>
28362836
<!--end::OverlayScrollbars Configure-->
2837-
<!--begin::Charts follow the colour mode-->
2838-
<script>
2839-
// ApexCharts draws light-theme tooltips and axis text unless told otherwise,
2840-
// which is unreadable in dark mode (#6105). Give it the page's colour mode as
2841-
// a global default before any chart is created — this runs before the chart
2842-
// pages' own scripts — and keep every chart that has a `chart.id` in step
2843-
// when the mode changes (ColorMode, the OS in auto mode, or your own code).
2844-
(() => {
2845-
'use strict';
2846-
const mode = () =>
2847-
document.documentElement.getAttribute('data-bs-theme') === 'dark' ? 'dark' : 'light';
2848-
// `Apex` is ApexCharts' global-options object; it must exist before the library loads.
2849-
// theme.mode also sets a dark chart background — keep the card's instead.
2850-
// eslint-disable-next-line unicorn/no-global-object-property-assignment
2851-
globalThis.Apex ||= {};
2852-
const apex = globalThis.Apex;
2853-
apex.theme = { mode: mode() };
2854-
apex.chart = Object.assign(apex.chart || {}, { background: 'transparent' });
2855-
new MutationObserver(() => {
2856-
const next = mode();
2857-
apex.theme = { mode: next };
2858-
const instances = apex._chartInstances || [];
2859-
for (const { chart } of instances) {
2860-
chart.updateOptions({ theme: { mode: next } }, false, false);
2861-
}
2862-
}).observe(document.documentElement, {
2863-
attributes: true,
2864-
attributeFilter: ['data-bs-theme'],
2865-
});
2866-
})();
2867-
</script>
2868-
<!--end::Charts follow the colour mode-->
28692837

28702838
<!--begin::Color Mode Toggle-->
28712839
<!-- The light/dark/auto switcher ships in adminlte.js as the ColorMode

‎dist/UI/icons.html‎

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@
818818
</a>
819819
<ul class="nav nav-treeview">
820820
<li class="nav-item">
821-
<a href="../charts/apexcharts.html" class="nav-link">
821+
<a href="../charts/chartjs.html" class="nav-link">
822822
<i class="nav-icon bi bi-circle"></i>
823-
<p>ApexCharts</p>
823+
<p>Chart.js</p>
824824
</a>
825825
</li>
826826
</ul>
@@ -1246,38 +1246,6 @@ <h3 class="card-title">Icons</h3>
12461246
});
12471247
</script>
12481248
<!--end::OverlayScrollbars Configure-->
1249-
<!--begin::Charts follow the colour mode-->
1250-
<script>
1251-
// ApexCharts draws light-theme tooltips and axis text unless told otherwise,
1252-
// which is unreadable in dark mode (#6105). Give it the page's colour mode as
1253-
// a global default before any chart is created — this runs before the chart
1254-
// pages' own scripts — and keep every chart that has a `chart.id` in step
1255-
// when the mode changes (ColorMode, the OS in auto mode, or your own code).
1256-
(() => {
1257-
'use strict';
1258-
const mode = () =>
1259-
document.documentElement.getAttribute('data-bs-theme') === 'dark' ? 'dark' : 'light';
1260-
// `Apex` is ApexCharts' global-options object; it must exist before the library loads.
1261-
// theme.mode also sets a dark chart background — keep the card's instead.
1262-
// eslint-disable-next-line unicorn/no-global-object-property-assignment
1263-
globalThis.Apex ||= {};
1264-
const apex = globalThis.Apex;
1265-
apex.theme = { mode: mode() };
1266-
apex.chart = Object.assign(apex.chart || {}, { background: 'transparent' });
1267-
new MutationObserver(() => {
1268-
const next = mode();
1269-
apex.theme = { mode: next };
1270-
const instances = apex._chartInstances || [];
1271-
for (const { chart } of instances) {
1272-
chart.updateOptions({ theme: { mode: next } }, false, false);
1273-
}
1274-
}).observe(document.documentElement, {
1275-
attributes: true,
1276-
attributeFilter: ['data-bs-theme'],
1277-
});
1278-
})();
1279-
</script>
1280-
<!--end::Charts follow the colour mode-->
12811249

12821250
<!--begin::Color Mode Toggle-->
12831251
<!-- The light/dark/auto switcher ships in adminlte.js as the ColorMode

‎dist/UI/ribbons.html‎

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@
818818
</a>
819819
<ul class="nav nav-treeview">
820820
<li class="nav-item">
821-
<a href="../charts/apexcharts.html" class="nav-link">
821+
<a href="../charts/chartjs.html" class="nav-link">
822822
<i class="nav-icon bi bi-circle"></i>
823-
<p>ApexCharts</p>
823+
<p>Chart.js</p>
824824
</a>
825825
</li>
826826
</ul>
@@ -1419,38 +1419,6 @@ <h6>Interactive ribbon</h6>
14191419
});
14201420
</script>
14211421
<!--end::OverlayScrollbars Configure-->
1422-
<!--begin::Charts follow the colour mode-->
1423-
<script>
1424-
// ApexCharts draws light-theme tooltips and axis text unless told otherwise,
1425-
// which is unreadable in dark mode (#6105). Give it the page's colour mode as
1426-
// a global default before any chart is created — this runs before the chart
1427-
// pages' own scripts — and keep every chart that has a `chart.id` in step
1428-
// when the mode changes (ColorMode, the OS in auto mode, or your own code).
1429-
(() => {
1430-
'use strict';
1431-
const mode = () =>
1432-
document.documentElement.getAttribute('data-bs-theme') === 'dark' ? 'dark' : 'light';
1433-
// `Apex` is ApexCharts' global-options object; it must exist before the library loads.
1434-
// theme.mode also sets a dark chart background — keep the card's instead.
1435-
// eslint-disable-next-line unicorn/no-global-object-property-assignment
1436-
globalThis.Apex ||= {};
1437-
const apex = globalThis.Apex;
1438-
apex.theme = { mode: mode() };
1439-
apex.chart = Object.assign(apex.chart || {}, { background: 'transparent' });
1440-
new MutationObserver(() => {
1441-
const next = mode();
1442-
apex.theme = { mode: next };
1443-
const instances = apex._chartInstances || [];
1444-
for (const { chart } of instances) {
1445-
chart.updateOptions({ theme: { mode: next } }, false, false);
1446-
}
1447-
}).observe(document.documentElement, {
1448-
attributes: true,
1449-
attributeFilter: ['data-bs-theme'],
1450-
});
1451-
})();
1452-
</script>
1453-
<!--end::Charts follow the colour mode-->
14541422

14551423
<!--begin::Color Mode Toggle-->
14561424
<!-- The light/dark/auto switcher ships in adminlte.js as the ColorMode

‎dist/UI/timeline.html‎

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@
818818
</a>
819819
<ul class="nav nav-treeview">
820820
<li class="nav-item">
821-
<a href="../charts/apexcharts.html" class="nav-link">
821+
<a href="../charts/chartjs.html" class="nav-link">
822822
<i class="nav-icon bi bi-circle"></i>
823-
<p>ApexCharts</p>
823+
<p>Chart.js</p>
824824
</a>
825825
</li>
826826
</ul>
@@ -1332,38 +1332,6 @@ <h3 class="timeline-header"><a href="#">Mr. Doe</a> shared a video</h3>
13321332
});
13331333
</script>
13341334
<!--end::OverlayScrollbars Configure-->
1335-
<!--begin::Charts follow the colour mode-->
1336-
<script>
1337-
// ApexCharts draws light-theme tooltips and axis text unless told otherwise,
1338-
// which is unreadable in dark mode (#6105). Give it the page's colour mode as
1339-
// a global default before any chart is created — this runs before the chart
1340-
// pages' own scripts — and keep every chart that has a `chart.id` in step
1341-
// when the mode changes (ColorMode, the OS in auto mode, or your own code).
1342-
(() => {
1343-
'use strict';
1344-
const mode = () =>
1345-
document.documentElement.getAttribute('data-bs-theme') === 'dark' ? 'dark' : 'light';
1346-
// `Apex` is ApexCharts' global-options object; it must exist before the library loads.
1347-
// theme.mode also sets a dark chart background — keep the card's instead.
1348-
// eslint-disable-next-line unicorn/no-global-object-property-assignment
1349-
globalThis.Apex ||= {};
1350-
const apex = globalThis.Apex;
1351-
apex.theme = { mode: mode() };
1352-
apex.chart = Object.assign(apex.chart || {}, { background: 'transparent' });
1353-
new MutationObserver(() => {
1354-
const next = mode();
1355-
apex.theme = { mode: next };
1356-
const instances = apex._chartInstances || [];
1357-
for (const { chart } of instances) {
1358-
chart.updateOptions({ theme: { mode: next } }, false, false);
1359-
}
1360-
}).observe(document.documentElement, {
1361-
attributes: true,
1362-
attributeFilter: ['data-bs-theme'],
1363-
});
1364-
})();
1365-
</script>
1366-
<!--end::Charts follow the colour mode-->
13671335

13681336
<!--begin::Color Mode Toggle-->
13691337
<!-- The light/dark/auto switcher ships in adminlte.js as the ColorMode

0 commit comments

Comments
 (0)