fix: 新增图表类型

This commit is contained in:
MTrun
2022-02-02 18:17:45 +08:00
parent 9876c7a802
commit 41711b174f
14 changed files with 200 additions and 36 deletions
@@ -0,0 +1,37 @@
import { getUUID } from '@/utils'
import { echartOptionProfixHandle } from '@/packages/utils/chart'
import { LineCommonConfig } from './index'
import { ConfigType, CreateComponentType } from '@/packages/index.d'
import omit from 'lodash/omit'
export default class Config implements CreateComponentType {
public id: string = getUUID()
public key: string = LineCommonConfig.key
public chartData: Exclude<ConfigType, ['node']> = omit(LineCommonConfig, ['node'])
public attr = { x: 0, y: 0, w: 500, h: 300 }
// 图表配置项
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'
}
]
})
// 设置坐标
public setPosition(x: number, y: number): void {
this.attr.x = x
this.attr.y = y
}
}
@@ -0,0 +1,7 @@
<template>
<div>配置项目</div>
</template>
<script setup lang="ts">
</script>
@@ -1,13 +1,36 @@
<template>
<div>
line组件渲染
</div>
<VChart theme="dark" :option="option" autoresize />
</template>
<script setup lang="ts">
import { computed, PropType } from 'vue'
import VChart from 'vue-echarts'
import { use, graphic } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { LineChart } from 'echarts/charts'
import {
GridComponent,
TooltipComponent,
LegendComponent
} from 'echarts/components'
import config from './config'
const props = defineProps({
chartData: {
type: Object as PropType<config>,
required: true
}
})
use([
CanvasRenderer,
LineChart,
GridComponent,
TooltipComponent,
LegendComponent
])
const option = computed(() => {
return props.chartData.option
})
</script>
<style lang="scss" scoped>
</style>