From fa265018f830c3ab12c84802d312754076747a6b Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Mon, 26 Jun 2023 12:01:00 +0200 Subject: [PATCH] remove cdn chart.js to import it --- package-lock.json | 13 +++++++++++++ package.json | 1 + resources/ts/app.ts | 1 + resources/ts/index.d.ts | 2 ++ resources/ts/pages/stats.ts | 2 ++ resources/views/layouts/backend/head.blade.php | 1 - .../views/stats/view-stats-by-brands.blade.php | 4 ++-- .../views/stats/view-stats-by-questions.blade.php | 2 +- 8 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 resources/ts/pages/stats.ts diff --git a/package-lock.json b/package-lock.json index 7d85520..69a1ffc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@vue/eslint-config-typescript": "^11.0.3", "axios": "^0.21", "bootstrap": "^5.3.0", + "chart.js": "^3.6.0", "clean-webpack-plugin": "^4.0.0", "eslint": "^8.42.0", "eslint-plugin-vue": "^9.14.1", @@ -4054,6 +4055,12 @@ "node": "*" } }, + "node_modules/chart.js": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.6.0.tgz", + "integrity": "sha512-iOzzDKePL+bj+ccIsVAgWQehCXv8xOKGbaU2fO/myivH736zcx535PGJzQGanvcSGVOqX6yuLZsN3ygcQ35UgQ==", + "dev": true + }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -15320,6 +15327,12 @@ "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", "dev": true }, + "chart.js": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.6.0.tgz", + "integrity": "sha512-iOzzDKePL+bj+ccIsVAgWQehCXv8xOKGbaU2fO/myivH736zcx535PGJzQGanvcSGVOqX6yuLZsN3ygcQ35UgQ==", + "dev": true + }, "chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", diff --git a/package.json b/package.json index 74299f4..293ad99 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@vue/eslint-config-typescript": "^11.0.3", "axios": "^0.21", "bootstrap": "^5.3.0", + "chart.js": "^3.6.0", "clean-webpack-plugin": "^4.0.0", "eslint": "^8.42.0", "eslint-plugin-vue": "^9.14.1", diff --git a/resources/ts/app.ts b/resources/ts/app.ts index cb06450..4426495 100644 --- a/resources/ts/app.ts +++ b/resources/ts/app.ts @@ -8,4 +8,5 @@ import "./pages/customer.delete"; import "./pages/data.delete"; import "./pages/service.index"; import "./pages/search-bar-brand"; +import "./pages/stats"; import "./pages/statsExport"; diff --git a/resources/ts/index.d.ts b/resources/ts/index.d.ts index ae5fb18..7b3ce28 100644 --- a/resources/ts/index.d.ts +++ b/resources/ts/index.d.ts @@ -1,5 +1,6 @@ export {}; import { AxiosStatic } from "axios"; +import { Chart } from "chart.js"; // * Enum interface EnumInterface { @@ -79,6 +80,7 @@ declare global { axios: AxiosStatic; Swal: Function; vueDebug: boolean | undefined; + ChartJS: typeof Chart; __SYSTEM: { _asset: string; _locale: string; diff --git a/resources/ts/pages/stats.ts b/resources/ts/pages/stats.ts new file mode 100644 index 0000000..575f09c --- /dev/null +++ b/resources/ts/pages/stats.ts @@ -0,0 +1,2 @@ +import Chart from "chart.js/auto"; +window.ChartJS = Chart; diff --git a/resources/views/layouts/backend/head.blade.php b/resources/views/layouts/backend/head.blade.php index 6508933..17265e6 100644 --- a/resources/views/layouts/backend/head.blade.php +++ b/resources/views/layouts/backend/head.blade.php @@ -40,6 +40,5 @@ @endif @push('scripts') - @endpush diff --git a/resources/views/stats/view-stats-by-brands.blade.php b/resources/views/stats/view-stats-by-brands.blade.php index 723f1c2..e9d5754 100644 --- a/resources/views/stats/view-stats-by-brands.blade.php +++ b/resources/views/stats/view-stats-by-brands.blade.php @@ -213,11 +213,11 @@ } }, }; - const chart = new Chart( + const chart = new ChartJS( document.getElementById('chart'), config ); } @endif }); - + diff --git a/resources/views/stats/view-stats-by-questions.blade.php b/resources/views/stats/view-stats-by-questions.blade.php index 3363045..b574f38 100644 --- a/resources/views/stats/view-stats-by-questions.blade.php +++ b/resources/views/stats/view-stats-by-questions.blade.php @@ -169,7 +169,7 @@ document.addEventListener("DOMContentLoaded", function(event) { } }, }; - const chart = new Chart( + const chart = new ChartJS( document.getElementById('chart'), config );