mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
commit
ce46f609ec
BIN
src/assets/images/chart/charts/dial.png
Normal file
BIN
src/assets/images/chart/charts/dial.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
91
src/packages/components/Charts/Mores/Dial/config.ts
Normal file
91
src/packages/components/Charts/Mores/Dial/config.ts
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
|
||||||
|
import { DialConfig } from './index'
|
||||||
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
|
||||||
|
export const includes = []
|
||||||
|
const option = {
|
||||||
|
backgroundColor: '#0E1327',
|
||||||
|
dataset:70,
|
||||||
|
series: [{
|
||||||
|
type: "gauge",
|
||||||
|
data: [{
|
||||||
|
value: 70,
|
||||||
|
itemStyle: { // 指针样式
|
||||||
|
color: '#2AF4FF'
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
min: 0, //最小刻度
|
||||||
|
max: 100, //最大刻度
|
||||||
|
splitNumber: 10, //刻度数量
|
||||||
|
center: ['50%', '55%'],
|
||||||
|
radius: '80%',
|
||||||
|
axisLine: {
|
||||||
|
lineStyle: {
|
||||||
|
color: [
|
||||||
|
[0, 'rgba(0,212,230,0.5)'],
|
||||||
|
[1, 'rgba(28,128,245,0)']
|
||||||
|
],
|
||||||
|
width: 170
|
||||||
|
}
|
||||||
|
},
|
||||||
|
axisLabel: { // 文字样式
|
||||||
|
color: '#eee',
|
||||||
|
fontSize: 14,
|
||||||
|
},
|
||||||
|
axisTick: {
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
splitLine: {
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
detail: {
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
pointer: {
|
||||||
|
length: '80%',
|
||||||
|
width: 4
|
||||||
|
},
|
||||||
|
animationDuration: 2000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '外部刻度',
|
||||||
|
type: 'gauge',
|
||||||
|
center: ['50%', '55%'],
|
||||||
|
radius: '90%',
|
||||||
|
axisLine: {
|
||||||
|
show: true,
|
||||||
|
lineStyle: {
|
||||||
|
width: 25,
|
||||||
|
color: [ // 表盘外部颜色
|
||||||
|
[0, '#1369E380'],
|
||||||
|
[1, '#1369E380']
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
axisLabel: {
|
||||||
|
show:false,
|
||||||
|
},
|
||||||
|
axisTick: {
|
||||||
|
splitNumber: 5,
|
||||||
|
lineStyle: { //刻度颜色
|
||||||
|
color: '#42E5FB',
|
||||||
|
width: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
splitLine: {
|
||||||
|
length: 15,
|
||||||
|
lineStyle: {
|
||||||
|
color: '#42E5FB',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||||
|
public key: string = DialConfig.key
|
||||||
|
public chartConfig = cloneDeep(DialConfig)
|
||||||
|
// 图表配置项
|
||||||
|
public option = echartOptionProfixHandle(option, includes)
|
||||||
|
}
|
84
src/packages/components/Charts/Mores/Dial/config.vue
Normal file
84
src/packages/components/Charts/Mores/Dial/config.vue
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 遍历 seriesList -->
|
||||||
|
<CollapseItem :name="`圆环`" :expanded="true">
|
||||||
|
<SettingItemBox name="数据">
|
||||||
|
<SettingItem name="数值">
|
||||||
|
<n-input-number v-model:value="config.dataset" :min="dialConfig.min" :max="dialConfig.max" :step="1" size="small" placeholder="数值">
|
||||||
|
</n-input-number>
|
||||||
|
</SettingItem>
|
||||||
|
</SettingItemBox>
|
||||||
|
<!-- Echarts 全局设置 -->
|
||||||
|
<!-- 表盘刻度字体 -->
|
||||||
|
<SettingItemBox name="字体">
|
||||||
|
<SettingItem name="颜色">
|
||||||
|
<n-color-picker size="small" :modes="['hex']" v-model:value="dialConfig.axisLabel.color"></n-color-picker>
|
||||||
|
</SettingItem>
|
||||||
|
<SettingItem name="字体大小">
|
||||||
|
<n-input-number
|
||||||
|
v-model:value="dialConfig.axisLabel.fontSize"
|
||||||
|
:min="0"
|
||||||
|
:step="1"
|
||||||
|
size="small"
|
||||||
|
placeholder="字体大小"
|
||||||
|
>
|
||||||
|
</n-input-number>
|
||||||
|
</SettingItem>
|
||||||
|
</SettingItemBox>
|
||||||
|
<!-- 表盘 -->
|
||||||
|
<SettingItemBox name="表盘外部">
|
||||||
|
<SettingItem name="颜色" >
|
||||||
|
<n-color-picker size="small" :modes="['hex']" v-model:value="config.series[1].axisLine.lineStyle.color[1][1]"></n-color-picker>
|
||||||
|
</SettingItem>
|
||||||
|
</SettingItemBox>
|
||||||
|
<!-- 指针 -->
|
||||||
|
<SettingItemBox name="指针">
|
||||||
|
<SettingItem name="颜色" >
|
||||||
|
<n-color-picker size="small" :modes="['hex']" v-model:value="dialConfig.data[0].itemStyle.color"></n-color-picker>
|
||||||
|
</SettingItem>
|
||||||
|
<SettingItem name="宽度">
|
||||||
|
<n-input-number v-model:value="dialConfig.pointer.width" :min="0" :step="1" size="small" placeholder="数值">
|
||||||
|
</n-input-number>
|
||||||
|
</SettingItem>
|
||||||
|
</SettingItemBox>
|
||||||
|
<SettingItemBox name="刻度">
|
||||||
|
<SettingItem name="最小值">
|
||||||
|
<n-input-number v-model:value="dialConfig.min" :min="0" :step="1" size="small" placeholder="数值">
|
||||||
|
</n-input-number>
|
||||||
|
</SettingItem>
|
||||||
|
<SettingItem name="最大值">
|
||||||
|
<n-input-number v-model:value="dialConfig.max" :min="0" :step="1" size="small" placeholder="数值">
|
||||||
|
</n-input-number>
|
||||||
|
</SettingItem>
|
||||||
|
<SettingItem name="颜色" >
|
||||||
|
<n-color-picker size="small" :modes="['hex']" v-model:value="config.series[1].axisTick.lineStyle.color" @update:value="updateClick"></n-color-picker>
|
||||||
|
</SettingItem>
|
||||||
|
</SettingItemBox>
|
||||||
|
|
||||||
|
</CollapseItem>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { PropType, computed } from 'vue'
|
||||||
|
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||||
|
import { GlobalThemeJsonType } from '@/settings/chartThemes'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
optionData: {
|
||||||
|
type: Object as PropType<GlobalThemeJsonType>,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const config = computed(() => {
|
||||||
|
return props.optionData
|
||||||
|
})
|
||||||
|
|
||||||
|
const dialConfig = computed(() => {
|
||||||
|
return props.optionData.series[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateClick = (val: any) => {
|
||||||
|
props.optionData.series[1].splitLine.lineStyle.color=val
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
14
src/packages/components/Charts/Mores/Dial/index.ts
Normal file
14
src/packages/components/Charts/Mores/Dial/index.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||||
|
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||||
|
|
||||||
|
export const DialConfig: ConfigType = {
|
||||||
|
key: 'Dial',
|
||||||
|
chartKey: 'VDial',
|
||||||
|
conKey: 'VCDial',
|
||||||
|
title: '表盘',
|
||||||
|
category: ChatCategoryEnum.MORE,
|
||||||
|
categoryName: ChatCategoryEnumName.MORE,
|
||||||
|
package: PackagesCategoryEnum.CHARTS,
|
||||||
|
chartFrame: ChartFrameEnum.COMMON,
|
||||||
|
image:'dial.png'
|
||||||
|
}
|
69
src/packages/components/Charts/Mores/Dial/index.vue
Normal file
69
src/packages/components/Charts/Mores/Dial/index.vue
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<template>
|
||||||
|
<v-chart :theme="themeColor" :init-options="initOptions" :option="option.value" autoresize> </v-chart>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { PropType, reactive, watch } from 'vue'
|
||||||
|
import VChart from 'vue-echarts'
|
||||||
|
import { useCanvasInitOptions } from '@/hooks/useCanvasInitOptions.hook'
|
||||||
|
import { use } from 'echarts/core'
|
||||||
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
|
import { PieChart } from 'echarts/charts'
|
||||||
|
import { mergeTheme } from '@/packages/public/chart'
|
||||||
|
import config, { includes } from './config'
|
||||||
|
import { useChartDataFetch } from '@/hooks'
|
||||||
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
|
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent, TitleComponent } from 'echarts/components'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
themeSetting: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
themeColor: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
chartConfig: {
|
||||||
|
type: Object as PropType<config>,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const initOptions = useCanvasInitOptions(props.chartConfig.option, props.themeSetting)
|
||||||
|
|
||||||
|
use([DatasetComponent, CanvasRenderer, PieChart, GridComponent, TooltipComponent, LegendComponent, TitleComponent])
|
||||||
|
|
||||||
|
const option = reactive({
|
||||||
|
value: {}
|
||||||
|
})
|
||||||
|
|
||||||
|
const dataHandle = (newData: any) => {
|
||||||
|
let config = props.chartConfig.option
|
||||||
|
config.series[0].data[0].value = newData
|
||||||
|
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||||
|
option.value = props.chartConfig.option
|
||||||
|
}
|
||||||
|
|
||||||
|
// 配置时
|
||||||
|
watch(
|
||||||
|
() => props.chartConfig.option.dataset,
|
||||||
|
newData => {
|
||||||
|
try {
|
||||||
|
dataHandle(newData)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
deep: false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// 预览时
|
||||||
|
useChartDataFetch(props.chartConfig, useChartEditStore, (resData: number) => {
|
||||||
|
// @ts-ignore
|
||||||
|
option.value.series[0].data[0].value = resData
|
||||||
|
})
|
||||||
|
</script>
|
@ -4,7 +4,8 @@ import { FunnelConfig } from './Funnel/index'
|
|||||||
import { HeatmapConfig } from './Heatmap/index'
|
import { HeatmapConfig } from './Heatmap/index'
|
||||||
import { WaterPoloConfig } from './WaterPolo/index'
|
import { WaterPoloConfig } from './WaterPolo/index'
|
||||||
import { TreeMapConfig } from './TreeMap/index'
|
import { TreeMapConfig } from './TreeMap/index'
|
||||||
|
import { DialConfig } from './Dial/index'
|
||||||
import { SankeyConfig } from './Sankey/index'
|
import { SankeyConfig } from './Sankey/index'
|
||||||
import { GraphConfig } from './Graph/index'
|
import { GraphConfig } from './Graph/index'
|
||||||
|
|
||||||
export default [ProcessConfig, RadarConfig, FunnelConfig, HeatmapConfig, WaterPoloConfig, TreeMapConfig, GraphConfig, SankeyConfig]
|
export default [ProcessConfig, RadarConfig, FunnelConfig, HeatmapConfig, WaterPoloConfig, TreeMapConfig, GraphConfig, SankeyConfig, DialConfig]
|
||||||
|
Loading…
Reference in New Issue
Block a user