-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEvents.svelte
38 lines (33 loc) · 935 Bytes
/
Events.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<script lang="ts">
import { onMount } from "svelte";
import { BarChartSimple } from "@carbon/charts-svelte";
import { ScaleTypes } from "@carbon/charts/interfaces";
let chart = null;
function barMouseOver(e: MouseEvent) {
console.log(e.detail);
}
onMount(() => {
return () => {
if (chart) chart.services.events.removeEventListener("bar-mouseover", barMouseOver);
};
});
$: if (chart) chart.services.events.addEventListener("bar-mouseover", barMouseOver);
</script>
<BarChartSimple
bind:chart
data={[
{ group: "Qty", value: 65000 },
{ group: "More", value: 29123 },
{ group: "Sold", value: 35213 },
{ group: "Restocking", value: 51213 },
{ group: "Misc", value: 16932 },
]}
options={{
title: "Simple bar (discrete)",
height: "400px",
axes: {
left: { mapsTo: "value" },
bottom: { mapsTo: "group", scaleType: ScaleTypes.LABELS },
},
}}
/>