fix: new-york component error.

This commit is contained in:
linbingquan 2024-09-24 22:02:45 +08:00
parent ec350df9d4
commit ba8ec8dcdd
5 changed files with 27 additions and 27 deletions

View File

@ -1,13 +1,13 @@
<script setup lang="ts" generic="T extends Record<string, any>"> <script setup lang="ts" generic="T extends Record<string, any>">
import { type BulletLegendItemInterface, CurveType } from '@unovis/ts'
import { VisArea, VisAxis, VisLine, VisXYContainer } from '@unovis/vue'
import { Area, Axis, Line } from '@unovis/ts'
import { type Component, computed, ref } from 'vue'
import { useMounted } from '@vueuse/core'
import { useId } from 'radix-vue'
import type { BaseChartProps } from '.' import type { BaseChartProps } from '.'
import { ChartCrosshair, ChartLegend, defaultColors } from '@/lib/registry/new-york/ui/chart' import { ChartCrosshair, ChartLegend, defaultColors } from '@/lib/registry/new-york/ui/chart'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { type BulletLegendItemInterface, CurveType } from '@unovis/ts'
import { Area, Axis, Line } from '@unovis/ts'
import { VisArea, VisAxis, VisLine, VisXYContainer } from '@unovis/vue'
import { useMounted } from '@vueuse/core'
import { useId } from 'radix-vue'
import { type Component, computed, ref } from 'vue'
const props = withDefaults(defineProps<BaseChartProps<T> & { const props = withDefaults(defineProps<BaseChartProps<T> & {
/** /**
@ -83,7 +83,7 @@ function handleLegendItemClick(d: BulletLegendItemInterface, i: number) {
<template v-for="(category, i) in categories" :key="category"> <template v-for="(category, i) in categories" :key="category">
<VisArea <VisArea
:x="(d: Data, i: number) => i" :x="(_: Data, i: number) => i"
:y="(d: Data) => d[category]" :y="(d: Data) => d[category]"
color="auto" color="auto"
:curve-type="curveType" :curve-type="curveType"
@ -98,7 +98,7 @@ function handleLegendItemClick(d: BulletLegendItemInterface, i: number) {
<template v-for="(category, i) in categories" :key="category"> <template v-for="(category, i) in categories" :key="category">
<VisLine <VisLine
:x="(d: Data, i: number) => i" :x="(_: Data, i: number) => i"
:y="(d: Data) => d[category]" :y="(d: Data) => d[category]"
:color="colors[i]" :color="colors[i]"
:curve-type="curveType" :curve-type="curveType"

View File

@ -1,12 +1,12 @@
<script setup lang="ts" generic="T extends Record<string, any>"> <script setup lang="ts" generic="T extends Record<string, any>">
import type { BulletLegendItemInterface } from '@unovis/ts' import type { BulletLegendItemInterface } from '@unovis/ts'
import { VisAxis, VisGroupedBar, VisStackedBar, VisXYContainer } from '@unovis/vue'
import { Axis, GroupedBar, StackedBar } from '@unovis/ts'
import { type Component, computed, ref } from 'vue'
import { useMounted } from '@vueuse/core'
import type { BaseChartProps } from '.' import type { BaseChartProps } from '.'
import { ChartCrosshair, ChartLegend, defaultColors } from '@/lib/registry/new-york/ui/chart' import { ChartCrosshair, ChartLegend, defaultColors } from '@/lib/registry/new-york/ui/chart'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { Axis, GroupedBar, StackedBar } from '@unovis/ts'
import { VisAxis, VisGroupedBar, VisStackedBar, VisXYContainer } from '@unovis/vue'
import { useMounted } from '@vueuse/core'
import { type Component, computed, ref } from 'vue'
const props = withDefaults(defineProps<BaseChartProps<T> & { const props = withDefaults(defineProps<BaseChartProps<T> & {
/** /**
@ -71,14 +71,14 @@ const selectorsBar = computed(() => props.type === 'grouped' ? GroupedBar.select
<ChartCrosshair v-if="showTooltip" :colors="colors" :items="legendItems" :custom-tooltip="customTooltip" :index="index" /> <ChartCrosshair v-if="showTooltip" :colors="colors" :items="legendItems" :custom-tooltip="customTooltip" :index="index" />
<VisBarComponent <VisBarComponent
:x="(d: Data, i: number) => i" :x="(_: Data, i: number) => i"
:y="categories.map(category => (d: Data) => d[category]) " :y="categories.map(category => (d: Data) => d[category]) "
:color="colors" :color="colors"
:rounded-corners="roundedCorners" :rounded-corners="roundedCorners"
:bar-padding="0.05" :bar-padding="0.05"
:attributes="{ :attributes="{
[selectorsBar]: { [selectorsBar]: {
opacity: (d: Data, i:number) => { opacity: (_: Data, i:number) => {
const pos = i % categories.length const pos = i % categories.length
return legendItems[pos]?.inactive ? filterOpacity : 1 return legendItems[pos]?.inactive ? filterOpacity : 1
}, },

View File

@ -1,11 +1,11 @@
<script setup lang="ts" generic="T extends Record<string, any>"> <script setup lang="ts" generic="T extends Record<string, any>">
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 type { BaseChartProps } from '.'
import { ChartSingleTooltip, defaultColors } from '@/lib/registry/new-york/ui/chart' import { ChartSingleTooltip, defaultColors } from '@/lib/registry/new-york/ui/chart'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { Donut } from '@unovis/ts'
import { VisDonut, VisSingleContainer } from '@unovis/vue'
import { useMounted } from '@vueuse/core'
import { type Component, computed, ref } from 'vue'
const props = withDefaults(defineProps<Pick<BaseChartProps<T>, 'data' | 'colors' | 'index' | 'margin' | 'showLegend' | 'showTooltip' | 'filterOpacity'> & { const props = withDefaults(defineProps<Pick<BaseChartProps<T>, 'data' | 'colors' | 'index' | 'margin' | 'showLegend' | 'showTooltip' | 'filterOpacity'> & {
/** /**
@ -79,7 +79,7 @@ const totalValue = computed(() => props.data.reduce((prev, curr) => {
:central-label="type === 'donut' ? valueFormatter(totalValue) : ''" :central-label="type === 'donut' ? valueFormatter(totalValue) : ''"
:events="{ :events="{
[Donut.selectors.segment]: { [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) { if (d?.data?.[index] === activeSegmentKey) {
activeSegmentKey = undefined activeSegmentKey = undefined
elements.forEach(el => el.style.opacity = '1') elements.forEach(el => el.style.opacity = '1')

View File

@ -1,12 +1,12 @@
<script setup lang="ts" generic="T extends Record<string, any>"> <script setup lang="ts" generic="T extends Record<string, any>">
import { type BulletLegendItemInterface, CurveType } from '@unovis/ts'
import { VisAxis, VisLine, VisXYContainer } from '@unovis/vue'
import { Axis, Line } from '@unovis/ts'
import { type Component, computed, ref } from 'vue'
import { useMounted } from '@vueuse/core'
import type { BaseChartProps } from '.' import type { BaseChartProps } from '.'
import { ChartCrosshair, ChartLegend, defaultColors } from '@/lib/registry/new-york/ui/chart' import { ChartCrosshair, ChartLegend, defaultColors } from '@/lib/registry/new-york/ui/chart'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { type BulletLegendItemInterface, CurveType } from '@unovis/ts'
import { Axis, Line } from '@unovis/ts'
import { VisAxis, VisLine, VisXYContainer } from '@unovis/vue'
import { useMounted } from '@vueuse/core'
import { type Component, computed, ref } from 'vue'
const props = withDefaults(defineProps<BaseChartProps<T> & { const props = withDefaults(defineProps<BaseChartProps<T> & {
/** /**
@ -64,7 +64,7 @@ function handleLegendItemClick(d: BulletLegendItemInterface, i: number) {
<template v-for="(category, i) in categories" :key="category"> <template v-for="(category, i) in categories" :key="category">
<VisLine <VisLine
:x="(d: Data, i: number) => i" :x="(_: Data, i: number) => i"
:y="(d: Data) => d[category]" :y="(d: Data) => d[category]"
:curve-type="curveType" :curve-type="curveType"
:color="colors[i]" :color="colors[i]"

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { VisCrosshair, VisTooltip } from '@unovis/vue'
import type { BulletLegendItemInterface } from '@unovis/ts' import type { BulletLegendItemInterface } from '@unovis/ts'
import { omit } from '@unovis/ts' import { omit } from '@unovis/ts'
import { VisCrosshair, VisTooltip } from '@unovis/vue'
import { type Component, createApp } from 'vue' import { type Component, createApp } from 'vue'
import { ChartTooltip } from '.' import { ChartTooltip } from '.'
@ -33,7 +33,7 @@ function template(d: any) {
} }
} }
function color(d: unknown, i: number) { function color(_: unknown, i: number) {
return props.colors[i] ?? 'transparent' return props.colors[i] ?? 'transparent'
} }
</script> </script>