Tried to implement graph, no success

This commit is contained in:
Donny 2024-08-30 10:56:06 -06:00
parent a4bae1a671
commit 78265cce34
4 changed files with 47 additions and 6 deletions

16
package-lock.json generated
View File

@ -9,7 +9,8 @@
"dependencies": { "dependencies": {
"@unovis/svelte": "^1.4.1", "@unovis/svelte": "^1.4.1",
"@unovis/ts": "^1.4.1", "@unovis/ts": "^1.4.1",
"chart.js": "^4.4.3" "chart.js": "^4.4.4",
"chartjs": "^0.3.24"
}, },
"devDependencies": { "devDependencies": {
"@skeletonlabs/skeleton": "2.10.2", "@skeletonlabs/skeleton": "2.10.2",
@ -2685,9 +2686,10 @@
} }
}, },
"node_modules/chart.js": { "node_modules/chart.js": {
"version": "4.4.3", "version": "4.4.4",
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.3.tgz", "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.4.tgz",
"integrity": "sha512-qK1gkGSRYcJzqrrzdR6a+I0vQ4/R+SoODXyAjscQ/4mzuNzySaMCd+hyVxitSY1+L2fjPD1Gbn+ibNqRmwQeLw==", "integrity": "sha512-emICKGBABnxhMjUjlYRR12PmOXhJ2eJjEHL2/dZlWjxRAZT1D8xplLFq5M0tMQK8ja+wBS/tuVEJB5C6r7VxJA==",
"license": "MIT",
"dependencies": { "dependencies": {
"@kurkle/color": "^0.3.0" "@kurkle/color": "^0.3.0"
}, },
@ -2695,6 +2697,12 @@
"pnpm": ">=8" "pnpm": ">=8"
} }
}, },
"node_modules/chartjs": {
"version": "0.3.24",
"resolved": "https://registry.npmjs.org/chartjs/-/chartjs-0.3.24.tgz",
"integrity": "sha512-h6G9qcDqmFYnSWqjWCzQMeOLiypS+pM6Fq2Rj7LPty8Kjx5yHonwwJ7oEHImZpQ2u9Pu36XGYfardvvBiQVrhg==",
"license": "MIT"
},
"node_modules/chokidar": { "node_modules/chokidar": {
"version": "3.6.0", "version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",

View File

@ -43,6 +43,7 @@
"dependencies": { "dependencies": {
"@unovis/svelte": "^1.4.1", "@unovis/svelte": "^1.4.1",
"@unovis/ts": "^1.4.1", "@unovis/ts": "^1.4.1",
"chart.js": "^4.4.3" "chart.js": "^4.4.4",
"chartjs": "^0.3.24"
} }
} }

View File

@ -0,0 +1,31 @@
<script>
import chartjs from 'chart.js/auto';
import { onMount } from 'svelte';
const chartValues = [20, 10, 5, 2, 20, 30, 45];
const chartLabels = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
let ctx;
let chartCanvas;
let chartData;
onMount(async (promise) => {
ctx = chartCanvas.getContext('2d');
var chart = new chartjs(ctx, {
type: 'line',
data: {
labels: chartLabels,
datasets: [{
label: 'Revenue',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: chartValues
}]
}
});
});
</script>
<div class="w-fill m-auto px-60 mt-10">
<canvas class="w-1/2" bind:this={chartCanvas} id="myChart"></canvas>
</div>

View File

@ -2,6 +2,7 @@
<script> <script>
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { createEventDispatcher } from 'svelte'; import { createEventDispatcher } from 'svelte';
import Chart from '$lib/components/graph/graph.svelte'
let homeBase = "https://apilicenses.mpe.ca"; let homeBase = "https://apilicenses.mpe.ca";
@ -82,6 +83,7 @@
onMount(() => { onMount(() => {
fetchLicenses(); fetchLicenses();
getCounts() getCounts()
}); });
// Utility function to determine availability // Utility function to determine availability
@ -216,4 +218,3 @@
</div> </div>
{/each} {/each}
</div> </div>