diff --git a/app/Features/History/Data/HistoryData.php b/app/Features/History/Data/HistoryData.php index 9cd7c04..b5c97af 100644 --- a/app/Features/History/Data/HistoryData.php +++ b/app/Features/History/Data/HistoryData.php @@ -9,12 +9,11 @@ use Spatie\LaravelData\Data; class HistoryData extends Data { - /** - * @property Collection $electricity - * @property Collection $gas - */ public function __construct( + + /** @var Collection */ public Collection $electricity, + /** @var Collection */ public Collection $gas, ) {} } diff --git a/package-lock.json b/package-lock.json index 362292b..4eb946a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "@tailwindcss/vite": "^4.1.11", "@vitejs/plugin-vue": "^6.0.0", "axios": "^1.19.0", + "chart.js": "^4.5.1", "clsx": "^2.1.1", "concurrently": "^9.0.1", "i18next": "^26.3.6", @@ -20,7 +21,8 @@ "tailwindcss": "^4.1.1", "typescript": "^5.2.2", "vite": "^8.0.0", - "vue": "^3.5.13" + "vue": "^3.5.13", + "vue-chartjs": "^5.3.4" }, "devDependencies": { "@eslint/js": "^9.19.0", @@ -484,6 +486,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@kurkle/color": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.4.tgz", + "integrity": "sha512-M5UknZPHRu3DEDWoipU6sE8PdkZ6Z/S+v4dD+Ke8IaNlpdSQah50lz1KtcFBa2vsdOnwbbnxJwVM4wty6udA5w==", + "license": "MIT" + }, "node_modules/@laravel/vite-plugin-wayfinder": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/@laravel/vite-plugin-wayfinder/-/vite-plugin-wayfinder-0.1.7.tgz", @@ -2420,6 +2428,18 @@ "node": ">=8" } }, + "node_modules/chart.js": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.5.1.tgz", + "integrity": "sha512-GIjfiT9dbmHRiYi6Nl2yFCq7kkwdkp1W/lp2J99rX0yo9tgJGn3lKQATztIjb5tVtevcBtIdICNWqlq5+E8/Pw==", + "license": "MIT", + "dependencies": { + "@kurkle/color": "^0.3.0" + }, + "engines": { + "pnpm": ">=8" + } + }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -6856,6 +6876,16 @@ } } }, + "node_modules/vue-chartjs": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/vue-chartjs/-/vue-chartjs-5.3.4.tgz", + "integrity": "sha512-x3Fqob8RQvrTdssfi9ecsCzEkFOd8JPmNwSkSQzdfKj/uBsRJs/Y88cZcZIEcPsTVfMGwMo4MOoihoDG2DoE/g==", + "license": "MIT", + "peerDependencies": { + "chart.js": "^4.1.1", + "vue": "^3.0.0-0 || ^2.7.0" + } + }, "node_modules/vue-eslint-parser": { "version": "10.4.1", "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-10.4.1.tgz", diff --git a/package.json b/package.json index 967606a..ab1c66b 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@tailwindcss/vite": "^4.1.11", "@vitejs/plugin-vue": "^6.0.0", "axios": "^1.19.0", + "chart.js": "^4.5.1", "clsx": "^2.1.1", "concurrently": "^9.0.1", "i18next": "^26.3.6", @@ -44,7 +45,8 @@ "tailwindcss": "^4.1.1", "typescript": "^5.2.2", "vite": "^8.0.0", - "vue": "^3.5.13" + "vue": "^3.5.13", + "vue-chartjs": "^5.3.4" }, "optionalDependencies": { "@rollup/rollup-linux-x64-gnu": "4.9.5", diff --git a/resources/js/features/history/components/Chart.vue b/resources/js/features/history/components/Chart.vue new file mode 100644 index 0000000..29b2f87 --- /dev/null +++ b/resources/js/features/history/components/Chart.vue @@ -0,0 +1,63 @@ + + + diff --git a/resources/js/features/history/pages/Index.vue b/resources/js/features/history/pages/Index.vue index 0e2270e..5fdab18 100644 --- a/resources/js/features/history/pages/Index.vue +++ b/resources/js/features/history/pages/Index.vue @@ -1,7 +1,8 @@ diff --git a/resources/js/features/history/viewmodels/HistoryViewModel.ts b/resources/js/features/history/viewmodels/HistoryViewModel.ts index 6c3ee75..64f8753 100644 --- a/resources/js/features/history/viewmodels/HistoryViewModel.ts +++ b/resources/js/features/history/viewmodels/HistoryViewModel.ts @@ -1,6 +1,7 @@ import { create } from 'axios'; import { ref } from 'vue'; import HistoryData = App.Features.History.Data.HistoryData; +import moment from 'moment'; export default function useHistoryViewModel() { const isLoading = ref(false); @@ -17,6 +18,18 @@ export default function useHistoryViewModel() { }, }) .then((res) => { + console.log( + res.data?.electricity.flatMap((e) => { + if (!e.totalPriceTaxIncluded) { + return; + } + + return { + label: moment(e.startDate).format('DD-MM-YYYY'), + value: e.totalPriceTaxIncluded?.toPrecision(2), + }; + }), + ); historyData.value = res.data; }) .finally(() => (isLoading.value = false)); diff --git a/resources/js/generated/generated.d.ts b/resources/js/generated/generated.d.ts index bf19586..325387a 100644 --- a/resources/js/generated/generated.d.ts +++ b/resources/js/generated/generated.d.ts @@ -17,10 +17,10 @@ declare namespace App { startDate: string; endDate: string; period: string; - marketPrice: number; - totalPriceTaxIncluded: number; - priceInclHandlingVat: number; - priceTaxWithVat: number; + marketPrice: number | null; + totalPriceTaxIncluded: number | null; + priceInclHandlingVat: number | null; + priceTaxWithVat: number | null; startDateDatetime: string; }; } @@ -41,8 +41,8 @@ declare namespace App { namespace History { namespace Data { export type HistoryData = { - electricity: Array; - gas: Array; + electricity: App.Data.ElectricityData[]; + gas: App.Data.GasData[]; }; } namespace Requests { diff --git a/resources/js/generated/typescript-transformer-manifest.json b/resources/js/generated/typescript-transformer-manifest.json index d75a1cd..1fed8d0 100644 --- a/resources/js/generated/typescript-transformer-manifest.json +++ b/resources/js/generated/typescript-transformer-manifest.json @@ -1,3 +1,3 @@ { - "generated.d.ts": "7ca8a9c7f0ae5e5498bdee87bb2f005d" + "generated.d.ts": "596cfad66b8ff3f8b6b98271630919ae" } \ No newline at end of file diff --git a/resources/js/lang/init.ts b/resources/js/lang/init.ts index c8e2a96..6da9671 100644 --- a/resources/js/lang/init.ts +++ b/resources/js/lang/init.ts @@ -1,9 +1,9 @@ import i18next from 'i18next'; import resources from './translations'; -await i18next.init(() => ({ +await i18next.init({ lng: 'nl', resources, -})); +}); export default i18next; diff --git a/resources/js/layouts/Layout.vue b/resources/js/layouts/Layout.vue index 322a350..bbd2106 100644 --- a/resources/js/layouts/Layout.vue +++ b/resources/js/layouts/Layout.vue @@ -16,5 +16,5 @@ import history from '@/routes/history'; -
+