mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-18 01:36:37 +08:00
optimize(projects): optimize example code about vtable
,vchart
This commit is contained in:
parent
b9e873e53c
commit
d1c6081c25
11839
pnpm-lock.yaml
11839
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,11 @@
|
|||||||
import { computed, effectScope, onScopeDispose, ref, watch } from 'vue';
|
import { computed, effectScope, onScopeDispose, ref, watch } from 'vue';
|
||||||
|
import { useElementSize } from '@vueuse/core';
|
||||||
import VChart, { registerLiquidChart } from '@visactor/vchart';
|
import VChart, { registerLiquidChart } from '@visactor/vchart';
|
||||||
import type { ISpec, ITheme } from '@visactor/vchart';
|
import type { ISpec, ITheme } from '@visactor/vchart';
|
||||||
import light from '@visactor/vchart-theme/public/light.json';
|
import light from '@visactor/vchart-theme/public/light.json';
|
||||||
import dark from '@visactor/vchart-theme/public/dark.json';
|
import dark from '@visactor/vchart-theme/public/dark.json';
|
||||||
import { useElementSize } from '@vueuse/core';
|
|
||||||
import { useThemeStore } from '@/store/modules/theme';
|
import { useThemeStore } from '@/store/modules/theme';
|
||||||
|
|
||||||
registerLiquidChart();
|
registerLiquidChart();
|
||||||
|
|
||||||
// register the theme
|
// register the theme
|
||||||
|
@ -1,4 +1,15 @@
|
|||||||
export const shapeWordCloudSpec = {
|
import type {
|
||||||
|
IAreaChartSpec,
|
||||||
|
IBarChartSpec,
|
||||||
|
ICircularProgressChartSpec,
|
||||||
|
IHistogramChartSpec,
|
||||||
|
IIndicatorSpec,
|
||||||
|
ILiquidChartSpec,
|
||||||
|
IWordCloudChartSpec
|
||||||
|
} from '@visactor/vchart';
|
||||||
|
import type { IAnimationConfig } from '@visactor/vgrammar-core';
|
||||||
|
|
||||||
|
export const shapeWordCloudSpec: IWordCloudChartSpec = {
|
||||||
type: 'wordCloud',
|
type: 'wordCloud',
|
||||||
maskShape: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/log.jpeg',
|
maskShape: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/log.jpeg',
|
||||||
nameField: 'challenge_name',
|
nameField: 'challenge_name',
|
||||||
@ -161,7 +172,7 @@ export const shapeWordCloudSpec = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export const circularProgressTickSpec = {
|
export const circularProgressTickSpec: ICircularProgressChartSpec & { indicator: IIndicatorSpec } = {
|
||||||
type: 'circularProgress',
|
type: 'circularProgress',
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
@ -244,7 +255,7 @@ export const circularProgressTickSpec = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const liquidChartSmartInvertSpec = {
|
export const liquidChartSmartInvertSpec: ILiquidChartSpec & { indicator: IIndicatorSpec } = {
|
||||||
type: 'liquid',
|
type: 'liquid',
|
||||||
valueField: 'value',
|
valueField: 'value',
|
||||||
data: {
|
data: {
|
||||||
@ -397,7 +408,7 @@ const dataSpecs = Object.keys(goldenMedals).map(year => {
|
|||||||
const duration = 1000;
|
const duration = 1000;
|
||||||
const exchangeDuration = 600;
|
const exchangeDuration = 600;
|
||||||
|
|
||||||
export const rankingBarSpec = {
|
export const rankingBarSpec: IBarChartSpec = {
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
padding: {
|
padding: {
|
||||||
top: 12,
|
top: 12,
|
||||||
@ -457,7 +468,7 @@ export const rankingBarSpec = {
|
|||||||
duration: exchangeDuration,
|
duration: exchangeDuration,
|
||||||
easing: 'circInOut'
|
easing: 'circInOut'
|
||||||
}
|
}
|
||||||
},
|
} as Record<string, IAnimationConfig>,
|
||||||
animationEnter: {
|
animationEnter: {
|
||||||
bar: [
|
bar: [
|
||||||
{
|
{
|
||||||
@ -534,7 +545,7 @@ export const rankingBarSpec = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const stackedDashAreaSpec = {
|
export const stackedDashAreaSpec: IAreaChartSpec = {
|
||||||
type: 'area',
|
type: 'area',
|
||||||
data: {
|
data: {
|
||||||
values: [
|
values: [
|
||||||
@ -616,7 +627,7 @@ export const stackedDashAreaSpec = {
|
|||||||
if (data.forecast) {
|
if (data.forecast) {
|
||||||
return 'bias-rl';
|
return 'bias-rl';
|
||||||
}
|
}
|
||||||
return null;
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -631,7 +642,7 @@ export const stackedDashAreaSpec = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const barMarkPointSpec = {
|
export const barMarkPointSpec: IBarChartSpec = {
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
height: 300,
|
height: 300,
|
||||||
data: [
|
data: [
|
||||||
@ -693,7 +704,7 @@ export const barMarkPointSpec = {
|
|||||||
},
|
},
|
||||||
itemContent: {
|
itemContent: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
autoRotate: false,
|
// autoRotate: false,
|
||||||
offsetY: -10,
|
offsetY: -10,
|
||||||
text: {
|
text: {
|
||||||
dy: 14,
|
dy: 14,
|
||||||
@ -765,7 +776,7 @@ export const barMarkPointSpec = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export const histogramDifferentBinSpec = {
|
export const histogramDifferentBinSpec: IHistogramChartSpec = {
|
||||||
type: 'histogram',
|
type: 'histogram',
|
||||||
xField: 'from',
|
xField: 'from',
|
||||||
x2Field: 'to',
|
x2Field: 'to',
|
||||||
@ -797,8 +808,8 @@ export const histogramDifferentBinSpec = {
|
|||||||
},
|
},
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
key: (datum: any) => `${datum.from}~${datum.to}`,
|
key: (datum?: Record<string, any>) => `${datum?.from}~${datum?.to}`,
|
||||||
value: (datum: any) => datum.profit
|
value: (datum?: Record<string, any>) => datum?.profit
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onUnmounted } from 'vue';
|
|
||||||
import type {
|
|
||||||
IAreaChartSpec,
|
|
||||||
IBarChartSpec,
|
|
||||||
ICircularProgressChartSpec,
|
|
||||||
IHistogramChartSpec,
|
|
||||||
ILiquidChartSpec
|
|
||||||
} from '@visactor/vchart';
|
|
||||||
import { useVChart } from '@/hooks/common/vchart';
|
import { useVChart } from '@/hooks/common/vchart';
|
||||||
import {
|
import {
|
||||||
barMarkPointSpec,
|
barMarkPointSpec,
|
||||||
@ -18,27 +10,20 @@ import {
|
|||||||
stackedDashAreaSpec
|
stackedDashAreaSpec
|
||||||
} from './data';
|
} from './data';
|
||||||
|
|
||||||
const { domRef: stackedDashAreaRef } = useVChart(() => stackedDashAreaSpec as IAreaChartSpec, { onRender() {} });
|
const { domRef: stackedDashAreaRef } = useVChart(() => stackedDashAreaSpec);
|
||||||
const { domRef: barMarkPointRef } = useVChart(() => barMarkPointSpec as IBarChartSpec, { onRender() {} });
|
const { domRef: barMarkPointRef } = useVChart(() => barMarkPointSpec);
|
||||||
const { domRef: histogramDifferentBinRef } = useVChart(() => histogramDifferentBinSpec as IHistogramChartSpec, {
|
const { domRef: histogramDifferentBinRef } = useVChart(() => histogramDifferentBinSpec);
|
||||||
onRender() {}
|
const { domRef: rankingBarRef } = useVChart(() => rankingBarSpec);
|
||||||
});
|
const { domRef: shapeWordCloudRef } = useVChart(() => shapeWordCloudSpec);
|
||||||
const { domRef: rankingBarRef } = useVChart(() => rankingBarSpec as IBarChartSpec, { onRender() {} });
|
const { domRef: circularProgressTickRef } = useVChart(() => circularProgressTickSpec);
|
||||||
const { domRef: shapeWordCloudRef } = useVChart(() => shapeWordCloudSpec, { onRender() {} });
|
const { domRef: liquidChartSmartInvertRef } = useVChart(() => liquidChartSmartInvertSpec);
|
||||||
const { domRef: circularProgressTickRef } = useVChart(() => circularProgressTickSpec as ICircularProgressChartSpec, {
|
|
||||||
onRender() {}
|
|
||||||
});
|
|
||||||
const { domRef: liquidChartSmartInvertRef } = useVChart(() => liquidChartSmartInvertSpec as ILiquidChartSpec, {
|
|
||||||
onRender() {}
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
// clearGaugeChart();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NSpace vertical :size="16">
|
<NSpace vertical :size="16">
|
||||||
|
<NCard :bordered="false" title="VChart" class="h-full card-wrapper">
|
||||||
|
<WebSiteLink label="More Demos: " link="https://www.visactor.com/vchart/example" />
|
||||||
|
</NCard>
|
||||||
<NCard title="Stacked Dash Area Chart" :bordered="false" class="h-full card-wrapper">
|
<NCard title="Stacked Dash Area Chart" :bordered="false" class="h-full card-wrapper">
|
||||||
<div ref="stackedDashAreaRef" class="h-400px" />
|
<div ref="stackedDashAreaRef" class="h-400px" />
|
||||||
</NCard>
|
</NCard>
|
||||||
@ -60,9 +45,6 @@ onUnmounted(() => {
|
|||||||
<NCard title="Shape Word Cloud Chart" :bordered="false" class="h-full card-wrapper">
|
<NCard title="Shape Word Cloud Chart" :bordered="false" class="h-full card-wrapper">
|
||||||
<div ref="shapeWordCloudRef" class="h-400px" />
|
<div ref="shapeWordCloudRef" class="h-400px" />
|
||||||
</NCard>
|
</NCard>
|
||||||
<NCard :bordered="false" class="h-full w-2/3 card-wrapper">
|
|
||||||
<WebSiteLink label="More VChart Demos: " link="https://www.visactor.com/vchart/example" />
|
|
||||||
</NCard>
|
|
||||||
</NSpace>
|
</NSpace>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -775,20 +775,18 @@ onUnmounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="h-full">
|
<NSpace vertical :size="16">
|
||||||
<NSpace vertical :size="16">
|
<NCard :bordered="false" title="VTableGantt" class="h-full card-wrapper">
|
||||||
<NCard :bordered="false" class="h-full w-2/3 card-wrapper">
|
<WebSiteLink label="More Demos: " link="https://www.visactor.com/vtable/example" />
|
||||||
<div ref="basicGanttDomRef" class="relative h-400px"></div>
|
</NCard>
|
||||||
</NCard>
|
<NCard :bordered="false" class="h-full card-wrapper">
|
||||||
<NCard :bordered="false" class="h-full w-2/3 card-wrapper">
|
<div ref="basicGanttDomRef" class="relative h-400px"></div>
|
||||||
<div ref="linkGanttDomRef" class="relative h-400px"></div>
|
</NCard>
|
||||||
</NCard>
|
<NCard :bordered="false" class="h-full card-wrapper">
|
||||||
<NCard :bordered="false" class="h-full w-2/3 card-wrapper">
|
<div ref="linkGanttDomRef" class="relative h-400px"></div>
|
||||||
<div ref="customGanttDomRef" class="relative h-400px"></div>
|
</NCard>
|
||||||
</NCard>
|
<NCard :bordered="false" class="h-full card-wrapper">
|
||||||
<NCard :bordered="false" class="h-full w-2/3 card-wrapper">
|
<div ref="customGanttDomRef" class="relative h-400px"></div>
|
||||||
<WebSiteLink label="More VTableGantt Demos: " link="https://www.visactor.com/vtable/example" />
|
</NCard>
|
||||||
</NCard>
|
</NSpace>
|
||||||
</NSpace>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user