mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
fix: 新增图表类型
This commit is contained in:
parent
9876c7a802
commit
41711b174f
@ -1,4 +1,5 @@
|
||||
import { getUUID } from '@/utils'
|
||||
import { echartOptionProfixHandle } from '@/packages/utils/chart'
|
||||
import { BarCommonConfig } from './index'
|
||||
import { ConfigType, CreateComponentType } from '@/packages/index.d'
|
||||
import omit from 'lodash/omit'
|
||||
@ -12,8 +13,7 @@ export default class Config implements CreateComponentType {
|
||||
public attr = { x: 0, y: 0, w: 500, h: 300 }
|
||||
|
||||
// 图表配置项
|
||||
public config = {
|
||||
backgroundColor: 'rgba(0,0,0,0)',
|
||||
public option = echartOptionProfixHandle({
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
@ -33,11 +33,11 @@ export default class Config implements CreateComponentType {
|
||||
type: 'bar'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// 设置坐标
|
||||
public setPosition(x: number, y: number): void {
|
||||
this.attr.x = x
|
||||
this.attr.y = y
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<v-chart theme="dark" :option="option" autoresize />
|
||||
<VChart theme="dark" :option="option" autoresize />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, toRef, PropType } from 'vue'
|
||||
import { computed, PropType } from 'vue'
|
||||
import VChart from 'vue-echarts'
|
||||
import { use, graphic } from 'echarts/core'
|
||||
import { CanvasRenderer } from 'echarts/renderers'
|
||||
@ -31,11 +31,6 @@ use([
|
||||
])
|
||||
|
||||
const option = computed(() => {
|
||||
return props.chartData.config
|
||||
return props.chartData.option
|
||||
})
|
||||
|
||||
const attr = toRef(props.chartData, 'attr')
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { getUUID } from '@/utils'
|
||||
import { echartOptionProfixHandle } from '@/packages/utils/chart'
|
||||
import { BarCrossrangefig } from './index'
|
||||
import { ConfigType, CreateComponentType } from '@/packages/index.d'
|
||||
import omit from 'lodash/omit'
|
||||
@ -12,7 +13,7 @@ export default class Config implements CreateComponentType {
|
||||
public attr = { x: 0, y: 0, w: 500, h: 300 }
|
||||
|
||||
// 图表配置项
|
||||
public config = {
|
||||
public option = echartOptionProfixHandle({
|
||||
backgroundColor: 'rgba(0,0,0,0)',
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
@ -33,7 +34,7 @@ export default class Config implements CreateComponentType {
|
||||
type: 'bar'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// 设置坐标
|
||||
public setPosition(x: number, y: number): void {
|
||||
|
@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<v-chart theme="dark" :option="option" autoresize />
|
||||
<VChart theme="dark" :option="option" autoresize />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, toRef, PropType } from 'vue'
|
||||
import { computed, PropType } from 'vue'
|
||||
import VChart from 'vue-echarts'
|
||||
import { use, graphic } from 'echarts/core'
|
||||
import { CanvasRenderer } from 'echarts/renderers'
|
||||
@ -31,11 +31,8 @@ use([
|
||||
])
|
||||
|
||||
const option = computed(() => {
|
||||
return props.chartData.config
|
||||
return props.chartData.option
|
||||
})
|
||||
|
||||
const attr = toRef(props.chartData, 'attr')
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
37
src/packages/components/Charts/Lines/LineCommon/config.ts
Normal file
37
src/packages/components/Charts/Lines/LineCommon/config.ts
Normal file
@ -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>
|
65
src/packages/components/Charts/Pies/PieCommon/config.ts
Normal file
65
src/packages/components/Charts/Pies/PieCommon/config.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import { getUUID } from '@/utils'
|
||||
import { echartOptionProfixHandle } from '@/packages/utils/chart'
|
||||
import { PieCommonConfig } 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 = PieCommonConfig.key
|
||||
|
||||
public chartData: Exclude<ConfigType, ['node']> = omit(PieCommonConfig, ['node'])
|
||||
|
||||
public attr = { x: 0, y: 0, w: 500, h: 300 }
|
||||
|
||||
// 图表配置项
|
||||
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
|
||||
}
|
||||
}
|
7
src/packages/components/Charts/Pies/PieCommon/config.vue
Normal file
7
src/packages/components/Charts/Pies/PieCommon/config.vue
Normal file
@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<div>配置项目</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
</script>
|
@ -5,7 +5,7 @@ import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const PieCommonConfig: ConfigType = {
|
||||
key: 'VPieCommon',
|
||||
title: '计量图',
|
||||
title: '饼图',
|
||||
category: ChatCategoryEnum.PIE,
|
||||
categoryName: ChatCategoryEnumName.PIE,
|
||||
package: PackagesCategoryEnum.CHARTS,
|
||||
|
@ -1,13 +1,36 @@
|
||||
<template>
|
||||
<div>
|
||||
饼图渲染
|
||||
</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 { PieChart } 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,
|
||||
PieChart,
|
||||
GridComponent,
|
||||
TooltipComponent,
|
||||
LegendComponent
|
||||
])
|
||||
|
||||
const option = computed(() => {
|
||||
return props.chartData.option
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
2
src/packages/index.d.ts
vendored
2
src/packages/index.d.ts
vendored
@ -18,7 +18,7 @@ export interface CreateComponentType {
|
||||
key: string
|
||||
attr: { x: number; y: number; w: number; h: number }
|
||||
chartData: ConfigType
|
||||
config: object
|
||||
option: object
|
||||
setPosition: Function
|
||||
}
|
||||
|
||||
|
8
src/packages/utils/chart.ts
Normal file
8
src/packages/utils/chart.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* * ECharts option 统一前置处理
|
||||
* @param option
|
||||
*/
|
||||
export const echartOptionProfixHandle = (option: any) => {
|
||||
option['backgroundColor'] = 'rgba(0,0,0,0)'
|
||||
return option
|
||||
}
|
1
src/packages/utils/index.ts
Normal file
1
src/packages/utils/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from '@/packages/utils/chart'
|
Loading…
x
Reference in New Issue
Block a user