diff --git a/src/components/ButtonDialog.vue b/src/components/ButtonDialog.vue
index 5ecb4a3..5ada4fb 100644
--- a/src/components/ButtonDialog.vue
+++ b/src/components/ButtonDialog.vue
@@ -14,7 +14,6 @@ import {
Card,
CardContent,
CardDescription,
- CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
diff --git a/src/components/ui/chart-bar/BarChart.vue b/src/components/ui/chart-bar/BarChart.vue
index bfaa601..27725d1 100644
--- a/src/components/ui/chart-bar/BarChart.vue
+++ b/src/components/ui/chart-bar/BarChart.vue
@@ -1,86 +1,122 @@
-
-
+
+
-
+
-import { VisDonut, VisSingleContainer } from '@unovis/vue'
-import { Donut } from '@unovis/ts'
-import { type Component, computed, ref } from 'vue'
-import { useMounted } from '@vueuse/core'
-import type { BaseChartProps } from '.'
-import { ChartSingleTooltip, defaultColors } from '@/components/ui/chart'
-import { cn } from '@/lib/utils'
+import { VisDonut, VisSingleContainer } from "@unovis/vue";
+import { Donut } from "@unovis/ts";
+import { type Component, computed, ref } from "vue";
+import { useMounted } from "@vueuse/core";
+import type { BaseChartProps } from ".";
+import { ChartSingleTooltip, defaultColors } from "@/components/ui/chart";
+import { cn } from "@/lib/utils";
-const props = withDefaults(defineProps, 'data' | 'colors' | 'index' | 'margin' | 'showLegend' | 'showTooltip' | 'filterOpacity'> & {
- /**
- * Sets the name of the key containing the quantitative chart values.
- */
- category: KeyOfT
- /**
- * Change the type of the chart
- * @default "donut"
- */
- type?: 'donut' | 'pie'
- /**
- * Function to sort the segment
- */
- sortFunction?: (a: any, b: any) => number | undefined
- /**
- * Controls the formatting for the label.
- */
- valueFormatter?: (tick: number, i?: number, ticks?: number[]) => string
- /**
- * Render custom tooltip component.
- */
- customTooltip?: Component
-}>(), {
- margin: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
- sortFunction: () => undefined,
- valueFormatter: (tick: number) => `${tick}`,
- type: 'donut',
- filterOpacity: 0.2,
- showTooltip: true,
- showLegend: true,
-})
+const props = withDefaults(
+ defineProps<
+ Pick<
+ BaseChartProps,
+ | "data"
+ | "colors"
+ | "index"
+ | "margin"
+ | "showLegend"
+ | "showTooltip"
+ | "filterOpacity"
+ > & {
+ /**
+ * Sets the name of the key containing the quantitative chart values.
+ */
+ category: KeyOfT;
+ /**
+ * Change the type of the chart
+ * @default "donut"
+ */
+ type?: "donut" | "pie";
+ /**
+ * Function to sort the segment
+ */
+ sortFunction?: (a: any, b: any) => number | undefined;
+ /**
+ * Controls the formatting for the label.
+ */
+ valueFormatter?: (tick: number, i?: number, ticks?: number[]) => string;
+ /**
+ * Render custom tooltip component.
+ */
+ customTooltip?: Component;
+ }
+ >(),
+ {
+ margin: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
+ sortFunction: () => undefined,
+ valueFormatter: (tick: number) => `${tick}`,
+ type: "donut",
+ filterOpacity: 0.2,
+ showTooltip: true,
+ showLegend: true,
+ },
+);
-type KeyOfT = Extract
-type Data = typeof props.data[number]
+type KeyOfT = Extract;
+type Data = (typeof props.data)[number];
-const category = computed(() => props.category as KeyOfT)
-const index = computed(() => props.index as KeyOfT)
+const category = computed(() => props.category as KeyOfT);
+const index = computed(() => props.index as KeyOfT);
-const isMounted = useMounted()
-const activeSegmentKey = ref()
-const colors = computed(() => props.colors?.length ? props.colors : defaultColors(props.data.filter(d => d[props.category]).filter(Boolean).length))
-const legendItems = computed(() => props.data.map((item, i) => ({
- name: item[props.index],
- color: colors.value[i],
- inactive: false,
-})))
+const isMounted = useMounted();
+const activeSegmentKey = ref();
+const colors = computed(() =>
+ props.colors?.length
+ ? props.colors
+ : defaultColors(
+ props.data.filter((d) => d[props.category]).filter(Boolean).length,
+ ),
+);
+const legendItems = computed(() =>
+ props.data.map((item, i) => ({
+ name: item[props.index],
+ color: colors.value[i],
+ inactive: false,
+ })),
+);
-const totalValue = computed(() => props.data.reduce((prev, curr) => {
- return prev + curr[props.category]
-}, 0))
+const totalValue = computed(() =>
+ props.data.reduce((prev, curr) => {
+ return prev + curr[props.category];
+ }, 0),
+);
-
+
props.data.reduce((prev, curr) => {
:central-label="type === 'donut' ? valueFormatter(totalValue) : ''"
:events="{
[Donut.selectors.segment]: {
- click: (d: Data, ev: PointerEvent, i: number, elements: HTMLElement[]) => {
+ click: (
+ d: Data,
+ _: PointerEvent,
+ i: number,
+ elements: HTMLElement[],
+ ) => {
if (d?.data?.[index] === activeSegmentKey) {
- activeSegmentKey = undefined
- elements.forEach(el => el.style.opacity = '1')
- }
- else {
- activeSegmentKey = d?.data?.[index]
- elements.forEach(el => el.style.opacity = `${filterOpacity}`)
- elements[i].style.opacity = '1'
+ activeSegmentKey = undefined;
+ elements.forEach((el) => (el.style.opacity = '1'));
+ } else {
+ activeSegmentKey = d?.data?.[index];
+ elements.forEach(
+ (el) => (el.style.opacity = `${filterOpacity}`),
+ );
+ elements[i].style.opacity = '1';
}
},
},
diff --git a/src/components/ui/chart/ChartCrosshair.vue b/src/components/ui/chart/ChartCrosshair.vue
index 4c47149..b624759 100644
--- a/src/components/ui/chart/ChartCrosshair.vue
+++ b/src/components/ui/chart/ChartCrosshair.vue
@@ -1,40 +1,47 @@
diff --git a/src/components/ui/chart/ChartLegend.vue b/src/components/ui/chart/ChartLegend.vue
index e77b644..0d4769a 100644
--- a/src/components/ui/chart/ChartLegend.vue
+++ b/src/components/ui/chart/ChartLegend.vue
@@ -1,50 +1,64 @@
-
+
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 87acea3..365058c 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -1,6 +1,5 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
-import { camelize, getCurrentInstance, toHandlerKey } from "vue";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));