import { html, css, cssManager } from '@design.estate/dees-element'; import type { DeesChartDonut } from './component.js'; import '@design.estate/dees-wcctools/demotools'; import './component.js'; export const demoFunc = () => { const diskData = [ { name: 'Documents', value: 42 }, { name: 'Media', value: 28 }, { name: 'Applications', value: 15 }, { name: 'System', value: 10 }, { name: 'Other', value: 5 }, ]; const statusData = [ { name: 'Healthy', value: 156 }, { name: 'Warning', value: 23 }, { name: 'Critical', value: 8 }, { name: 'Unknown', value: 3 }, ]; const trafficData = [ { name: 'API', value: 45200 }, { name: 'Static Assets', value: 23100 }, { name: 'WebSocket', value: 12800 }, { name: 'GraphQL', value: 8900 }, ]; return html` { const diskChart = elementArg.querySelector('#disk-chart') as DeesChartDonut; const statusChart = elementArg.querySelector('#status-chart') as DeesChartDonut; const trafficChart = elementArg.querySelector('#traffic-chart') as DeesChartDonut; // Wire up buttons const buttons = elementArg.querySelectorAll('dees-button'); buttons.forEach((button: any) => { const text = button.text?.trim(); if (text === 'Randomize') { button.addEventListener('click', () => { diskChart.data = diskData.map((d) => ({ ...d, value: Math.round(d.value * (0.5 + Math.random())), })); statusChart.data = statusData.map((d) => ({ ...d, value: Math.round(d.value * (0.3 + Math.random() * 1.4)), })); trafficChart.data = trafficData.map((d) => ({ ...d, value: Math.round(d.value * (0.5 + Math.random())), })); }); } }); }}>
Randomize
`${val} GB`} > `${val} services`} .innerRadiusPercent=${'0%'} >
`${(val / 1000).toFixed(1)}k req`} >
Donut chart with configurable inner radius (set to 0% for full pie) • Click 'Randomize' to update data with animation
`; };