mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
perf: 优化雷达图展示
This commit is contained in:
parent
24ede6ac4f
commit
15e9a0c0f5
@ -22,6 +22,8 @@ export const option = {
|
|||||||
dataset: { ...dataJson },
|
dataset: { ...dataJson },
|
||||||
radar: {
|
radar: {
|
||||||
shape: 'polygon',
|
shape: 'polygon',
|
||||||
|
radius: ['0%', '60%'],
|
||||||
|
center: ['50%', '55%'],
|
||||||
splitArea: { show: true },
|
splitArea: { show: true },
|
||||||
splitLine: { show: true },
|
splitLine: { show: true },
|
||||||
axisName: { show: true, color: '#eee', fontSize: 12 },
|
axisName: { show: true, color: '#eee', fontSize: 12 },
|
||||||
@ -31,7 +33,7 @@ export const option = {
|
|||||||
},
|
},
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name: 'Budget vs spending',
|
name: 'radar',
|
||||||
type: 'radar',
|
type: 'radar',
|
||||||
areaStyle: {
|
areaStyle: {
|
||||||
opacity: 0.1
|
opacity: 0.1
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- Echarts 全局设置 -->
|
<!-- Echarts 全局设置 -->
|
||||||
<global-setting :optionData="optionData" :in-chart="true"></global-setting>
|
<global-setting :optionData="optionData" :in-chart="true"></global-setting>
|
||||||
|
|
||||||
<CollapseItem name="雷达" :expanded="true">
|
<CollapseItem name="雷达" :expanded="true">
|
||||||
<SettingItemBox name="样式">
|
<SettingItemBox name="样式">
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
@ -11,9 +12,65 @@
|
|||||||
<n-checkbox v-model:checked="radarConfig.splitLine.show">分割线</n-checkbox>
|
<n-checkbox v-model:checked="radarConfig.splitLine.show">分割线</n-checkbox>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem name="雷达形状">
|
<SettingItem name="雷达形状">
|
||||||
<n-select v-model:value="radarConfig.shape" :options="RadarShapeEnumList" placeholder="选择形状" />
|
<n-select v-model:value="radarConfig.shape" size="small" :options="RadarShapeEnumList" placeholder="选择形状" />
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
</SettingItemBox>
|
</SettingItemBox>
|
||||||
|
|
||||||
|
<SettingItemBox name="坐标轴">
|
||||||
|
<SettingItem>
|
||||||
|
<n-checkbox v-model:checked="radarConfig.axisLine.show">轴线</n-checkbox>
|
||||||
|
</SettingItem>
|
||||||
|
<SettingItem>
|
||||||
|
<n-checkbox v-model:checked="radarConfig.axisTick.show">刻度</n-checkbox>
|
||||||
|
</SettingItem>
|
||||||
|
</SettingItemBox>
|
||||||
|
|
||||||
|
<SettingItemBox name="范围">
|
||||||
|
<setting-item :name="`最小值:${radarProp.radius[0]}%`">
|
||||||
|
<!-- 透明度 -->
|
||||||
|
<n-slider
|
||||||
|
v-model:value="radarProp.radius[0]"
|
||||||
|
:min="0"
|
||||||
|
:max="100"
|
||||||
|
:format-tooltip="sliderFormatTooltip"
|
||||||
|
@update:value="updateRadius0"
|
||||||
|
></n-slider>
|
||||||
|
</setting-item>
|
||||||
|
<setting-item :name="`最大值:${radarProp.radius[1]}%`">
|
||||||
|
<!-- 透明度 -->
|
||||||
|
<n-slider
|
||||||
|
v-model:value="radarProp.radius[1]"
|
||||||
|
:min="0"
|
||||||
|
:max="100"
|
||||||
|
:format-tooltip="sliderFormatTooltip"
|
||||||
|
@update:value="updateRadius1"
|
||||||
|
></n-slider>
|
||||||
|
</setting-item>
|
||||||
|
</SettingItemBox>
|
||||||
|
|
||||||
|
<SettingItemBox name="偏移">
|
||||||
|
<setting-item :name="`X 轴值:${radarProp.center[0]}%`">
|
||||||
|
<!-- 透明度 -->
|
||||||
|
<n-slider
|
||||||
|
v-model:value="radarProp.center[0]"
|
||||||
|
:min="0"
|
||||||
|
:max="100"
|
||||||
|
:format-tooltip="sliderFormatTooltip"
|
||||||
|
@update:value="updateCenter0"
|
||||||
|
></n-slider>
|
||||||
|
</setting-item>
|
||||||
|
<setting-item :name="`Y 轴值:${radarProp.center[1]}%`">
|
||||||
|
<!-- 透明度 -->
|
||||||
|
<n-slider
|
||||||
|
v-model:value="radarProp.center[1]"
|
||||||
|
:min="0"
|
||||||
|
:max="100"
|
||||||
|
:format-tooltip="sliderFormatTooltip"
|
||||||
|
@update:value="updateCenter1"
|
||||||
|
></n-slider>
|
||||||
|
</setting-item>
|
||||||
|
</SettingItemBox>
|
||||||
|
|
||||||
<SettingItemBox name="指示器">
|
<SettingItemBox name="指示器">
|
||||||
<SettingItem name="颜色">
|
<SettingItem name="颜色">
|
||||||
<n-color-picker size="small" :modes="['hex']" v-model:value="radarConfig.axisName.color"></n-color-picker>
|
<n-color-picker size="small" :modes="['hex']" v-model:value="radarConfig.axisName.color"></n-color-picker>
|
||||||
@ -25,14 +82,7 @@
|
|||||||
<n-checkbox v-model:checked="radarConfig.axisName.show">文字标签</n-checkbox>
|
<n-checkbox v-model:checked="radarConfig.axisName.show">文字标签</n-checkbox>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
</SettingItemBox>
|
</SettingItemBox>
|
||||||
<SettingItemBox name="坐标轴">
|
|
||||||
<SettingItem>
|
|
||||||
<n-checkbox v-model:checked="radarConfig.axisLine.show">轴线</n-checkbox>
|
|
||||||
</SettingItem>
|
|
||||||
<SettingItem>
|
|
||||||
<n-checkbox v-model:checked="radarConfig.axisTick.show">刻度</n-checkbox>
|
|
||||||
</SettingItem>
|
|
||||||
</SettingItemBox>
|
|
||||||
<SettingItemBox name="系列" :alone="true">
|
<SettingItemBox name="系列" :alone="true">
|
||||||
<SettingItem name="背景透明度">
|
<SettingItem name="背景透明度">
|
||||||
<n-input-number
|
<n-input-number
|
||||||
@ -49,19 +99,46 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PropType, computed } from 'vue'
|
import { PropType, computed, reactive } from 'vue'
|
||||||
import { GlobalSetting, CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
import { GlobalSetting, CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||||
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
import { option, RadarShapeEnumList } from './config'
|
||||||
import { RadarShapeEnumList } from './config'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
optionData: {
|
optionData: {
|
||||||
type: Object as PropType<GlobalThemeJsonType>,
|
type: Object as PropType<typeof option>,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const radarConfig = computed(() => {
|
const radarConfig = computed<typeof option.radar>(() => {
|
||||||
return props.optionData.radar
|
return props.optionData.radar
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const radarProp = reactive({
|
||||||
|
radius: [0, 60],
|
||||||
|
center: [50, 50]
|
||||||
|
})
|
||||||
|
|
||||||
|
// 更新处理
|
||||||
|
const updateRadius0 = (value: number) => {
|
||||||
|
props.optionData.radar.radius[0] = `${value}%`
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateRadius1 = (value: number) => {
|
||||||
|
props.optionData.radar.radius[1] = `${value}%`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新处理
|
||||||
|
const updateCenter0 = (value: number) => {
|
||||||
|
props.optionData.radar.center[0] = `${value}%`
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateCenter1 = (value: number) => {
|
||||||
|
props.optionData.radar.center[1] = `${value}%`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 百分比格式化 percent
|
||||||
|
const sliderFormatTooltip = (v: number) => {
|
||||||
|
return `${v}%`
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
{
|
{
|
||||||
"radarIndicator": [
|
"radarIndicator": [
|
||||||
{ "name": "Sales", "max": 6500 },
|
{ "name": "数据1", "max": 6500 },
|
||||||
{ "name": "Administration", "max": 16000 },
|
{ "name": "数据2", "max": 16000 },
|
||||||
{ "name": "Information Technology", "max": 30000 },
|
{ "name": "数据3", "max": 30000 },
|
||||||
{ "name": "Customer Support", "max": 38000 },
|
{ "name": "数据4", "max": 38000 },
|
||||||
{ "name": "Development", "max": 52000 },
|
{ "name": "数据5", "max": 52000 },
|
||||||
{ "name": "Marketing", "max": 25000 }
|
{ "name": "数据6", "max": 25000 }
|
||||||
],
|
],
|
||||||
"seriesData": [
|
"seriesData": [
|
||||||
{
|
{
|
||||||
"value": [4200, 3000, 20000, 35000, 50000, 18000],
|
"value": [4200, 3000, 20000, 35000, 50000, 18000],
|
||||||
"name": "Allocated Budget"
|
"name": "data1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": [5000, 14000, 28000, 26000, 42000, 21000],
|
"value": [5000, 14000, 28000, 26000, 42000, 21000],
|
||||||
"name": "Actual Spending"
|
"name": "data2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,15 @@ const option = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataSetHandle = (dataset: any) => {
|
const dataSetHandle = (dataset: any) => {
|
||||||
props.chartConfig.option.legend.data = dataset.seriesData.map(i => i.name)
|
if (props.chartConfig.option.legend && dataset.seriesData) {
|
||||||
props.chartConfig.option.radar.indicator = dataset.radarIndicator
|
props.chartConfig.option.legend.data = dataset.seriesData.map((i: { name: string }) => i.name)
|
||||||
props.chartConfig.option.series[0].data = dataset.seriesData
|
}
|
||||||
|
if (dataset.radarIndicator) {
|
||||||
|
props.chartConfig.option.radar.indicator = dataset.radarIndicator
|
||||||
|
}
|
||||||
|
if (dataset.seriesData) {
|
||||||
|
props.chartConfig.option.series[0].data = dataset.seriesData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
"top": "5%",
|
"top": "5%",
|
||||||
"textStyle": {
|
"textStyle": {
|
||||||
"color": "#B9B8CE"
|
"color": "#B9B8CE"
|
||||||
}
|
},
|
||||||
|
"data": []
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user