-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: add radar chart with placeholder info
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import { localItems } from '$lib/utils/locales'; | ||
import { languageTag } from '$paraglide/runtime'; | ||
// export let name: string; | ||
export let s_label = ''; | ||
export let width = 'w-auto'; | ||
export let height = 'h-full'; | ||
export let classesContainer = ''; | ||
export let title = ''; | ||
export let values: any[]; // Set the types for these variables later on | ||
export let colors: string[] = []; | ||
for (const index in values) { | ||
if (values[index].localName) { | ||
values[index].name = localItems(languageTag())[values[index].localName]; | ||
} | ||
} | ||
let chart_element: HTMLElement | null = null; | ||
onMount(async () => { | ||
const echarts = await import('echarts'); | ||
let chart = echarts.init(chart_element, null, { renderer: 'svg' }); | ||
// specify chart configuration item and data | ||
let option = { | ||
title: { | ||
text: title, | ||
textStyle: { | ||
fontWeight: 'bold', | ||
fontSize: 14 | ||
} | ||
// show: false | ||
}, | ||
tooltip: { | ||
trigger: 'item' | ||
}, | ||
legend: { | ||
data: ['Allocated Budget', 'Actual Spending'] | ||
}, | ||
radar: { | ||
//shape: 'circle', | ||
indicator: [ | ||
{ name: 'Rogue Admin', }, | ||
{ name: 'Unavailability', }, | ||
{ name: 'Regulation', }, | ||
{ name: 'Data Breach', }, | ||
{ name: 'Phishing', }, | ||
{ name: 'Ransomware', } | ||
] | ||
}, | ||
series: [ | ||
{ | ||
name: 'Budget vs spending', | ||
type: 'radar', | ||
data: [ | ||
{ | ||
value: [500, 600, 700, 800, 900, 1000], | ||
name: 'Current' | ||
}, | ||
] | ||
} | ||
] | ||
}; | ||
// console.debug(option); | ||
// use configuration item and data specified to show chart | ||
chart.setOption(option); | ||
window.addEventListener('resize', function () { | ||
chart.resize(); | ||
}); | ||
}); | ||
</script> | ||
|
||
<div class="{width} {height} {classesContainer}" bind:this={chart_element} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters