feat: 修改组件展示,支持单个组件数据编辑

This commit is contained in:
MTrun
2022-02-24 17:23:20 +08:00
parent a4198bf75a
commit 7918918a69
17 changed files with 219 additions and 175 deletions
@@ -3,59 +3,59 @@ import { PieCommonConfig } from './index'
import { CreateComponentType } from '@/packages/index.d'
import omit from 'lodash/omit'
export const includes = ['legend']
const option = echartOptionProfixHandle({
tooltip: {
show: true,
trigger: 'item'
},
legend: {
show: true,
top: '5%',
left: 'center'
},
series: [
{
name: 'Access From',
type: 'pie',
radius: ['40%', '70%'],
avoidLabelOverlap: false,
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: '40',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
data: [
{ value: 1048, name: 'Search Engine' },
{ value: 735, name: 'Direct' },
{ value: 580, name: 'Email' },
{ value: 484, name: 'Union Ads' },
{ value: 300, name: 'Video Ads' }
]
}
]
}, includes)
export default class Config extends publicConfig implements CreateComponentType {
public key: string = PieCommonConfig.key
public chartData = omit(PieCommonConfig, ['node'])
public chartConfig = omit(PieCommonConfig, ['node'])
// 图表配置项
public option = echartOptionProfixHandle({
tooltip: {
trigger: 'item'
},
legend: {
top: '5%',
left: 'center'
},
series: [
{
name: 'Access From',
type: 'pie',
radius: ['40%', '70%'],
avoidLabelOverlap: false,
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: '40',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
data: [
{ value: 1048, name: 'Search Engine' },
{ value: 735, name: 'Direct' },
{ value: 580, name: 'Email' },
{ value: 484, name: 'Union Ads' },
{ value: 300, name: 'Video Ads' }
]
}
]
})
// 设置坐标
public setPosition(x: number, y: number): void {
this.attr.x = x
this.attr.y = y
}
public option = option
}
@@ -9,12 +9,11 @@ import { use, graphic } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { PieChart } from 'echarts/charts'
import { mergeTheme } from '@/packages/public/chart'
import config from './config'
import config, { includes } from './config'
import {
GridComponent,
TooltipComponent,
LegendComponent,
TitleComponent
} from 'echarts/components'
const props = defineProps({
@@ -26,7 +25,7 @@ const props = defineProps({
type: Object,
required: true
},
chartData: {
chartConfig: {
type: Object as PropType<config>,
required: true
}
@@ -38,12 +37,10 @@ use([
GridComponent,
TooltipComponent,
LegendComponent,
TitleComponent
])
const includes = ['title', 'legend']
const option = computed(() => {
return mergeTheme( props.chartData.option, props.themeSetting, includes)
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
})
</script>