mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
feat: 饼图类型新增可选
This commit is contained in:
parent
0ddbdfce57
commit
ae42dec906
@ -5,7 +5,20 @@ import dataJson from './data.json'
|
|||||||
|
|
||||||
export const includes = ['legend']
|
export const includes = ['legend']
|
||||||
|
|
||||||
|
export enum PieTypeEnum {
|
||||||
|
NORMAL = '常规图',
|
||||||
|
RING = '环形图',
|
||||||
|
ROSE = '玫瑰图'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PieTypeObject = {
|
||||||
|
[PieTypeEnum.NORMAL]: 'nomal',
|
||||||
|
[PieTypeEnum.RING]: 'ring',
|
||||||
|
[PieTypeEnum.ROSE]: 'rose'
|
||||||
|
}
|
||||||
|
|
||||||
const option = {
|
const option = {
|
||||||
|
type: 'ring',
|
||||||
tooltip: {
|
tooltip: {
|
||||||
show: true,
|
show: true,
|
||||||
trigger: 'item'
|
trigger: 'item'
|
||||||
@ -19,6 +32,7 @@ const option = {
|
|||||||
type: 'pie',
|
type: 'pie',
|
||||||
radius: ['40%', '65%'],
|
radius: ['40%', '65%'],
|
||||||
center: ['50%', '60%'],
|
center: ['50%', '60%'],
|
||||||
|
roseType: false,
|
||||||
avoidLabelOverlap: false,
|
avoidLabelOverlap: false,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -1,17 +1,48 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- Echarts 全局设置 -->
|
<!-- Echarts 全局设置 -->
|
||||||
<global-setting :optionData="optionData"></global-setting>
|
<global-setting :optionData="optionData" ></global-setting>
|
||||||
|
<CollapseItem name="饼图配置" :expanded="true">
|
||||||
|
<SettingItemBox name="类型">
|
||||||
|
<SettingItem>
|
||||||
|
<n-select
|
||||||
|
v-model:value="optionData.type"
|
||||||
|
size="small"
|
||||||
|
:options="fontWeightOptions"
|
||||||
|
/>
|
||||||
|
</SettingItem>
|
||||||
|
</SettingItemBox>
|
||||||
|
</CollapseItem>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PropType } from 'vue'
|
import { PropType, watch } from "vue";
|
||||||
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
import { GlobalThemeJsonType } from "@/settings/chartThemes/index";
|
||||||
import { GlobalSetting } from '@/components/Pages/ChartItemSetting'
|
import {
|
||||||
|
GlobalSetting,
|
||||||
|
CollapseItem,
|
||||||
|
SettingItemBox,
|
||||||
|
SettingItem,
|
||||||
|
} from "@/components/Pages/ChartItemSetting";
|
||||||
|
import { PieTypeObject, PieTypeEnum } from "./config";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
optionData: {
|
optionData: {
|
||||||
type: Object as PropType<GlobalThemeJsonType>,
|
type: Object as PropType<GlobalThemeJsonType>,
|
||||||
required: true
|
required: true,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
const fontWeightOptions = [
|
||||||
|
{
|
||||||
|
label: PieTypeEnum.NORMAL,
|
||||||
|
value: PieTypeObject[PieTypeEnum.NORMAL],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: PieTypeEnum.RING,
|
||||||
|
value: PieTypeObject[PieTypeEnum.RING],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: PieTypeEnum.ROSE,
|
||||||
|
value: PieTypeObject[PieTypeEnum.ROSE],
|
||||||
|
},
|
||||||
|
];
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,39 +1,45 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-chart ref="vChartRef" :theme="themeColor" :option="option" :manual-update="isPreview()" autoresize></v-chart>
|
<v-chart
|
||||||
|
ref="vChartRef"
|
||||||
|
:theme="themeColor"
|
||||||
|
:option="option"
|
||||||
|
:manual-update="isPreview()"
|
||||||
|
autoresize
|
||||||
|
></v-chart>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, PropType } from 'vue'
|
import { computed, PropType, reactive, watch } from "vue";
|
||||||
import VChart from 'vue-echarts'
|
import VChart from "vue-echarts";
|
||||||
import { use } from 'echarts/core'
|
import { use } from "echarts/core";
|
||||||
import { CanvasRenderer } from 'echarts/renderers'
|
import { CanvasRenderer } from "echarts/renderers";
|
||||||
import { PieChart } from 'echarts/charts'
|
import { PieChart } from "echarts/charts";
|
||||||
import { mergeTheme } from '@/packages/public/chart'
|
import { mergeTheme } from "@/packages/public/chart";
|
||||||
import config, { includes } from './config'
|
import config, { includes } from "./config";
|
||||||
import { useChartDataFetch } from '@/hooks'
|
import { useChartDataFetch } from "@/hooks";
|
||||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
import { useChartEditStore } from "@/store/modules/chartEditStore/chartEditStore";
|
||||||
import { isPreview } from '@/utils'
|
import { isPreview } from "@/utils";
|
||||||
import {
|
import {
|
||||||
DatasetComponent,
|
DatasetComponent,
|
||||||
GridComponent,
|
GridComponent,
|
||||||
TooltipComponent,
|
TooltipComponent,
|
||||||
LegendComponent,
|
LegendComponent,
|
||||||
} from 'echarts/components'
|
} from "echarts/components";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
themeSetting: {
|
themeSetting: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
themeColor: {
|
themeColor: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true,
|
||||||
},
|
},
|
||||||
chartConfig: {
|
chartConfig: {
|
||||||
type: Object as PropType<config>,
|
type: Object as PropType<config>,
|
||||||
required: true
|
required: true,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
use([
|
use([
|
||||||
DatasetComponent,
|
DatasetComponent,
|
||||||
@ -42,12 +48,28 @@ use([
|
|||||||
GridComponent,
|
GridComponent,
|
||||||
TooltipComponent,
|
TooltipComponent,
|
||||||
LegendComponent,
|
LegendComponent,
|
||||||
])
|
]);
|
||||||
|
|
||||||
|
|
||||||
const option = computed(() => {
|
const option = computed(() => {
|
||||||
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||||
})
|
})
|
||||||
|
|
||||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
|
watch(
|
||||||
|
() => props.chartConfig.option.type,
|
||||||
|
(newData) => {
|
||||||
|
if (newData === "nomal") {
|
||||||
|
props.chartConfig.option.series[0].radius = "70%";
|
||||||
|
props.chartConfig.option.series[0].roseType = false;
|
||||||
|
} else if (newData === "ring") {
|
||||||
|
props.chartConfig.option.series[0].radius = ["40%", "65%"];
|
||||||
|
props.chartConfig.option.series[0].roseType = false;
|
||||||
|
} else {
|
||||||
|
props.chartConfig.option.series[0].radius = "70%";
|
||||||
|
props.chartConfig.option.series[0].roseType = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore);
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user