mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-04-03 14:37:29 +02:00
Initial migration to Svelte5 via full syntax compatability
- updated all dependencies - removed svelte-chartjs wrapper from dependencies - sveltestrap causes compilation warnings (once) - Header.svelte uses new Svelte5 syntax as example - fixed most initial compilation warnings except circular dependencies with TBD cause
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<!--
|
||||
@component Pie Plot based on uPlot Pie
|
||||
@component Pie Plot based on chart.js Pie
|
||||
|
||||
Properties:
|
||||
- `size Number`: X and Y size of the plot, for square shape
|
||||
@@ -31,33 +31,17 @@
|
||||
]
|
||||
</script>
|
||||
<script>
|
||||
import { Pie } from 'svelte-chartjs';
|
||||
import {
|
||||
Chart as ChartJS,
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend,
|
||||
Filler,
|
||||
ArcElement,
|
||||
CategoryScale
|
||||
} from 'chart.js';
|
||||
|
||||
ChartJS.register(
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend,
|
||||
Filler,
|
||||
ArcElement,
|
||||
CategoryScale
|
||||
);
|
||||
import Chart from 'chart.js/auto'
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let canvasId
|
||||
export let size
|
||||
export let sliceLabel
|
||||
export let quantities
|
||||
export let entities
|
||||
export let displayLegend = false
|
||||
|
||||
$: data = {
|
||||
const data = {
|
||||
labels: entities,
|
||||
datasets: [
|
||||
{
|
||||
@@ -79,10 +63,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
new Chart(
|
||||
document.getElementById(canvasId),
|
||||
{
|
||||
type: 'pie',
|
||||
data: data,
|
||||
options: options
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <div style="width: 500px;"><canvas id="dimensions"></canvas></div><br/> -->
|
||||
<div class="chart-container" style="--container-width: {size}; --container-height: {size}">
|
||||
<Pie {data} {options}/>
|
||||
<canvas id={canvasId}></canvas>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user