mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
feat: 修改组件展示,支持单个组件数据编辑
This commit is contained in:
@@ -3,35 +3,38 @@ import { LineCommonConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import omit from 'lodash/omit'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
|
||||
const options = echartOptionProfixHandle({
|
||||
legend: {
|
||||
show: true,
|
||||
},
|
||||
xAxis: {
|
||||
show: true,
|
||||
type: 'category',
|
||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||
},
|
||||
yAxis: {
|
||||
show: true,
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'data1',
|
||||
type: 'line',
|
||||
data: [120, 200, 150, 80, 70, 110, 130]
|
||||
},
|
||||
{
|
||||
name: 'data2',
|
||||
type: 'line',
|
||||
data: [130, 130, 312, 268, 155, 117, 160]
|
||||
}
|
||||
]
|
||||
}, includes)
|
||||
|
||||
export default class Config extends publicConfig implements CreateComponentType {
|
||||
public key: string = LineCommonConfig.key
|
||||
|
||||
public chartData = omit(LineCommonConfig, ['node'])
|
||||
|
||||
public chartConfig = omit(LineCommonConfig, ['node'])
|
||||
// 图表配置项
|
||||
public option = echartOptionProfixHandle({
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data: [150, 230, 224, 218, 135, 147, 260],
|
||||
type: 'line'
|
||||
},
|
||||
{
|
||||
data: [130, 130, 312, 268, 155, 117, 160],
|
||||
type: 'line'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// 设置坐标
|
||||
public setPosition(x: number, y: number): void {
|
||||
this.attr.x = x
|
||||
this.attr.y = y
|
||||
}
|
||||
public option = options
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import VChart from 'vue-echarts'
|
||||
import { use, graphic } from 'echarts/core'
|
||||
import { CanvasRenderer } from 'echarts/renderers'
|
||||
import { LineChart } from 'echarts/charts'
|
||||
import config from './config'
|
||||
import config, { includes } from './config'
|
||||
import { mergeTheme } from '@/packages/public/chart'
|
||||
import {
|
||||
GridComponent,
|
||||
@@ -26,7 +26,7 @@ const props = defineProps({
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
chartData: {
|
||||
chartConfig: {
|
||||
type: Object as PropType<config>,
|
||||
required: true
|
||||
}
|
||||
@@ -41,9 +41,7 @@ use([
|
||||
TitleComponent
|
||||
])
|
||||
|
||||
const includes = ['title', 'legend', 'xAxis', 'yAxis']
|
||||
|
||||
const option = computed(() => {
|
||||
return mergeTheme( props.chartData.option, props.themeSetting, includes)
|
||||
return mergeTheme( props.chartConfig.option, props.themeSetting, includes)
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user