Merge branch 'dev'
@ -156,6 +156,8 @@ Cloud IDE 代码在线预览地址:[https://idegitee.com/dromara/go-view](http
|
||||
|
||||
- 封装:项目进行了详细的工具类封装如:路由、存储、加/解密、文件处理、主题、NaiveUI 全局方法、组件等
|
||||
|
||||
- 可视化:基于开源图表库[ECharts](https://echarts.apache.org/zh/index.html) 和 [VChart](https://www.visactor.io/vchart) 编写,具有丰富的图表类型和适配大屏的主题效果;
|
||||
|
||||
- 入选 NaiveUI 社区精选资源推荐:[查看 NaiveUI 推荐列表](https://www.naiveui.com/zh-CN/light/docs/community)
|
||||
|
||||
说明文档:
|
||||
|
BIN
src/assets/images/chart/vchart/vchart_area.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
src/assets/images/chart/vchart/vchart_funnel.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
src/assets/images/chart/vchart/vchart_line.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
src/assets/images/chart/vchart/vchart_percent_area.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
src/assets/images/chart/vchart/vchart_pie.png
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
src/assets/images/chart/vchart/vchart_scatter.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
src/assets/images/chart/vchart/vchart_word_cloud.png
Normal file
After Width: | Height: | Size: 28 KiB |
32
src/components/GoVChart/transformProps/areas.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { cloneDeep } from "lodash"
|
||||
|
||||
export default (chartProps: any) => {
|
||||
const spec = cloneDeep(chartProps)
|
||||
delete spec.category
|
||||
|
||||
// tooltip
|
||||
const keyFill = spec.tooltip.style.keyLabel.fill
|
||||
const valueFill = spec.tooltip.style.valueLabel.fill
|
||||
const titleFill = spec.tooltip.style.titleLabel.keyFill
|
||||
delete spec.tooltip.style.keyLabel.fill
|
||||
delete spec.tooltip.style.valueLabel.fill
|
||||
delete spec.tooltip.style.titleLabel.keyFill
|
||||
spec.tooltip.style.keyLabel.fontColor = keyFill
|
||||
spec.tooltip.style.valueLabel.fontColor = valueFill
|
||||
spec.tooltip.style.titleLabel.fontColor = titleFill
|
||||
|
||||
// axis
|
||||
const { name: xAxisName, ...restXAxisProps } = chartProps.xAxis
|
||||
const { name: yAxisName, ...restYAxisProps } = chartProps.yAxis
|
||||
spec.axes = [{
|
||||
orient: 'bottom',
|
||||
...restXAxisProps
|
||||
}, {
|
||||
orient: 'left',
|
||||
...restYAxisProps
|
||||
}]
|
||||
delete spec.xAxis
|
||||
delete spec.yAxis
|
||||
// console.log('spec-area-transform', spec)
|
||||
return spec
|
||||
}
|
@ -20,13 +20,15 @@ export default (chartProps: any) => {
|
||||
const { name: yAxisName, ...restYAxisProps } = chartProps.yAxis
|
||||
spec.axes = [{
|
||||
orient: 'bottom',
|
||||
...restXAxisProps
|
||||
...restXAxisProps,
|
||||
// paddingInner: 0.5
|
||||
}, {
|
||||
orient: 'left',
|
||||
...restYAxisProps
|
||||
}]
|
||||
|
||||
delete spec.xAxis
|
||||
delete spec.yAxis
|
||||
console.log('spec-transform', spec)
|
||||
// console.log('spec-bar-transform', spec)
|
||||
return spec
|
||||
}
|
28
src/components/GoVChart/transformProps/funnels.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Datum } from "@visactor/vchart/esm/typings"
|
||||
import { cloneDeep } from "lodash"
|
||||
const INNER_RADIUS = 0.75
|
||||
const OUTER_RADIUS = 0.68
|
||||
|
||||
export default (chartProps: any) => {
|
||||
const spec = cloneDeep(chartProps)
|
||||
|
||||
|
||||
// tooltip
|
||||
const keyFill = spec.tooltip.style.keyLabel.fill
|
||||
const valueFill = spec.tooltip.style.valueLabel.fill
|
||||
const titleFill = spec.tooltip.style.titleLabel.keyFill
|
||||
delete spec.tooltip.style.keyLabel.fill
|
||||
delete spec.tooltip.style.valueLabel.fill
|
||||
delete spec.tooltip.style.titleLabel.keyFill
|
||||
spec.tooltip.style.keyLabel.fontColor = keyFill
|
||||
spec.tooltip.style.valueLabel.fontColor = valueFill
|
||||
spec.tooltip.style.titleLabel.fontColor = titleFill
|
||||
|
||||
// label
|
||||
spec.label = {
|
||||
visible: true,
|
||||
}
|
||||
|
||||
// console.log('spec-funnel-transform', spec)
|
||||
return spec
|
||||
}
|
@ -1,8 +1,20 @@
|
||||
import { ChatCategoryEnum, IOption } from "@/packages/components/VChart/index.d";
|
||||
import bars from './bars'
|
||||
import pies from './pies'
|
||||
import lines from './lines'
|
||||
import areas from './areas'
|
||||
import funnels from "./funnels";
|
||||
import wordClouds from "./wordClouds";
|
||||
import scatters from "./scatters";
|
||||
export const transformHandler: {
|
||||
[key: string]: (args: IOption) => any
|
||||
} = {
|
||||
[ChatCategoryEnum.BAR]: bars,
|
||||
[ChatCategoryEnum.PIE]: pies,
|
||||
[ChatCategoryEnum.LINE]: lines,
|
||||
[ChatCategoryEnum.AREA]: areas,
|
||||
[ChatCategoryEnum.FUNNEL]: funnels,
|
||||
[ChatCategoryEnum.WORDCLOUD]: wordClouds,
|
||||
[ChatCategoryEnum.SCATTER]: scatters,
|
||||
// todo: more charts handler
|
||||
}
|
32
src/components/GoVChart/transformProps/lines.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { cloneDeep } from "lodash"
|
||||
|
||||
export default (chartProps: any) => {
|
||||
const spec = cloneDeep(chartProps)
|
||||
delete spec.category
|
||||
|
||||
// tooltip
|
||||
const keyFill = spec.tooltip.style.keyLabel.fill
|
||||
const valueFill = spec.tooltip.style.valueLabel.fill
|
||||
const titleFill = spec.tooltip.style.titleLabel.keyFill
|
||||
delete spec.tooltip.style.keyLabel.fill
|
||||
delete spec.tooltip.style.valueLabel.fill
|
||||
delete spec.tooltip.style.titleLabel.keyFill
|
||||
spec.tooltip.style.keyLabel.fontColor = keyFill
|
||||
spec.tooltip.style.valueLabel.fontColor = valueFill
|
||||
spec.tooltip.style.titleLabel.fontColor = titleFill
|
||||
|
||||
// axis
|
||||
const { name: xAxisName, ...restXAxisProps } = chartProps.xAxis
|
||||
const { name: yAxisName, ...restYAxisProps } = chartProps.yAxis
|
||||
spec.axes = [{
|
||||
orient: 'bottom',
|
||||
...restXAxisProps
|
||||
}, {
|
||||
orient: 'left',
|
||||
...restYAxisProps
|
||||
}]
|
||||
delete spec.xAxis
|
||||
delete spec.yAxis
|
||||
// console.log('spec-line-transform', spec)
|
||||
return spec
|
||||
}
|
139
src/components/GoVChart/transformProps/pies.ts
Normal file
@ -0,0 +1,139 @@
|
||||
import { Datum } from "@visactor/vchart/esm/typings"
|
||||
import { cloneDeep } from "lodash"
|
||||
const INNER_RADIUS = 0.75
|
||||
const OUTER_RADIUS = 0.68
|
||||
|
||||
export default (chartProps: any) => {
|
||||
const spec = cloneDeep(chartProps)
|
||||
delete spec.category
|
||||
|
||||
spec.innerRadius = INNER_RADIUS
|
||||
spec.outerRadius = OUTER_RADIUS
|
||||
|
||||
// tooltip
|
||||
const keyFill = spec.tooltip.style.keyLabel.fill
|
||||
const valueFill = spec.tooltip.style.valueLabel.fill
|
||||
const titleFill = spec.tooltip.style.titleLabel.keyFill
|
||||
delete spec.tooltip.style.keyLabel.fill
|
||||
delete spec.tooltip.style.valueLabel.fill
|
||||
delete spec.tooltip.style.titleLabel.keyFill
|
||||
spec.tooltip.style.keyLabel.fontColor = keyFill
|
||||
spec.tooltip.style.valueLabel.fontColor = valueFill
|
||||
spec.tooltip.style.titleLabel.fontColor = titleFill
|
||||
|
||||
// extensionMark
|
||||
spec.extensionMark = [
|
||||
{
|
||||
name: 'arc_inner_shadow',
|
||||
type: 'arc',
|
||||
dataId: 'id0',
|
||||
style: {
|
||||
interactive: false,
|
||||
startAngle: (datum: Datum) => {
|
||||
console.log('startAngle', datum)
|
||||
return datum['__VCHART_ARC_START_ANGLE'];
|
||||
},
|
||||
endAngle: (datum: Datum) => {
|
||||
return datum['__VCHART_ARC_END_ANGLE'];
|
||||
},
|
||||
innerRadius: (datum: Datum, context: any) => {
|
||||
return context.getLayoutRadius() * spec.innerRadius - 30;
|
||||
},
|
||||
outerRadius: (datum: Datum, context: any) => {
|
||||
return context.getLayoutRadius() * spec.innerRadius;
|
||||
},
|
||||
fillOpacity: 0.3,
|
||||
fill: (datum: Datum, context: any) => {
|
||||
console.log('context', context.seriesColor(datum[spec.seriesField]))
|
||||
return context.seriesColor(datum[spec.seriesField]);
|
||||
},
|
||||
visible: true,
|
||||
x: (datum: Datum, context: any) => {
|
||||
return context.getCenter().x();
|
||||
},
|
||||
y: (datum: Datum, context: any) => {
|
||||
return context.getCenter().y();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'arc_inner',
|
||||
type: 'symbol',
|
||||
// dataId: 'id0',
|
||||
style: {
|
||||
interactive: false,
|
||||
size: (datum: Datum, context: any) => {
|
||||
return context.getLayoutRadius() * 2 * spec.innerRadius - 100;
|
||||
},
|
||||
fillOpacity: 0,
|
||||
lineWidth: 1,
|
||||
strokeOpacity: 0.5,
|
||||
stroke: {
|
||||
gradient: 'conical',
|
||||
startAngle: 0,
|
||||
endAngle: Math.PI * 2,
|
||||
stops: [
|
||||
{
|
||||
offset: 0,
|
||||
color: '#FFF',
|
||||
opacity: 0
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: '#FFF',
|
||||
opacity: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
visible: true,
|
||||
x: (datum: Datum, context: any) => {
|
||||
return context.getCenter().x();
|
||||
},
|
||||
y: (datum: Datum, context: any) => {
|
||||
return context.getCenter().y();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'arc_outer',
|
||||
type: 'symbol',
|
||||
// dataId: 'id0',
|
||||
style: {
|
||||
interactive: false,
|
||||
size: (datum: Datum, context: any) => {
|
||||
return context.getLayoutRadius() * 2 * spec.outerRadius + 50;
|
||||
},
|
||||
fillOpacity: 0,
|
||||
lineWidth: 1,
|
||||
strokeOpacity: 0.5,
|
||||
stroke: {
|
||||
gradient: 'conical',
|
||||
startAngle: 0,
|
||||
endAngle: Math.PI * 2,
|
||||
stops: [
|
||||
{
|
||||
offset: 0,
|
||||
color: '#FFF',
|
||||
opacity: 0
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: '#FFF',
|
||||
opacity: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
visible: true,
|
||||
x: (datum: Datum, context: any) => {
|
||||
return context.getCenter().x();
|
||||
},
|
||||
y: (datum: Datum, context: any) => {
|
||||
return context.getCenter().y();
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
// console.log('spec-pie-transform', spec)
|
||||
return spec
|
||||
}
|
35
src/components/GoVChart/transformProps/scatters.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { cloneDeep } from "lodash"
|
||||
|
||||
export default (chartProps: any) => {
|
||||
const spec = cloneDeep(chartProps)
|
||||
|
||||
// tooltip
|
||||
const keyFill = spec.tooltip.style.keyLabel.fill
|
||||
const valueFill = spec.tooltip.style.valueLabel.fill
|
||||
const titleFill = spec.tooltip.style.titleLabel.keyFill
|
||||
delete spec.tooltip.style.keyLabel.fill
|
||||
delete spec.tooltip.style.valueLabel.fill
|
||||
delete spec.tooltip.style.titleLabel.keyFill
|
||||
spec.tooltip.style.keyLabel.fontColor = keyFill
|
||||
spec.tooltip.style.valueLabel.fontColor = valueFill
|
||||
spec.tooltip.style.titleLabel.fontColor = titleFill
|
||||
|
||||
// axis
|
||||
const { name: xAxisName, ...restXAxisProps } = chartProps.xAxis
|
||||
const { name: yAxisName, ...restYAxisProps } = chartProps.yAxis
|
||||
spec.axes = [{
|
||||
orient: 'bottom',
|
||||
...restXAxisProps,
|
||||
label: {
|
||||
formatMethod: (value: string) => Number(value).toFixed(2)
|
||||
}
|
||||
}, {
|
||||
orient: 'left',
|
||||
...restYAxisProps
|
||||
}]
|
||||
|
||||
delete spec.xAxis
|
||||
delete spec.yAxis
|
||||
// console.log('spec-scatter-transform', spec)
|
||||
return spec
|
||||
}
|
21
src/components/GoVChart/transformProps/wordClouds.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { Datum } from "@visactor/vchart/esm/typings"
|
||||
import { cloneDeep } from "lodash"
|
||||
|
||||
export default (chartProps: any) => {
|
||||
const spec = cloneDeep(chartProps)
|
||||
|
||||
// tooltip
|
||||
const keyFill = spec.tooltip.style.keyLabel.fill
|
||||
const valueFill = spec.tooltip.style.valueLabel.fill
|
||||
const titleFill = spec.tooltip.style.titleLabel.keyFill
|
||||
delete spec.tooltip.style.keyLabel.fill
|
||||
delete spec.tooltip.style.valueLabel.fill
|
||||
delete spec.tooltip.style.titleLabel.keyFill
|
||||
spec.tooltip.style.keyLabel.fontColor = keyFill
|
||||
spec.tooltip.style.valueLabel.fontColor = valueFill
|
||||
spec.tooltip.style.titleLabel.fontColor = titleFill
|
||||
|
||||
|
||||
// console.log('spec-word-cloud-transform', spec)
|
||||
return spec
|
||||
}
|
47
src/packages/components/VChart/Areas/VChartArea/config.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { VChartAreaConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { vChartOptionPrefixHandle } from '@/packages/public/vChart'
|
||||
import data from './data.json'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import axisThemeJson from '@/settings/vchartThemes/axis.theme.json'
|
||||
import { IAreaOption } from '../../index.d'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
export const option: IAreaOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'area',
|
||||
dataset: data,
|
||||
xField: 'type',
|
||||
yField: 'value',
|
||||
seriesField: 'country',
|
||||
stack: true,
|
||||
// 业务配置(后续会被转换为图表spec)
|
||||
category: VChartAreaConfig.category,
|
||||
xAxis: {
|
||||
name: 'x轴',
|
||||
...axisThemeJson,
|
||||
grid: {
|
||||
...axisThemeJson.grid,
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
name: 'y轴',
|
||||
...axisThemeJson,
|
||||
grid: {
|
||||
...axisThemeJson.grid,
|
||||
style: {
|
||||
...axisThemeJson.grid.style,
|
||||
lineDash: [3, 3]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = VChartAreaConfig.key
|
||||
public chartConfig = cloneDeep(VChartAreaConfig)
|
||||
// 图表配置项
|
||||
public option = vChartOptionPrefixHandle(option, includes)
|
||||
}
|
19
src/packages/components/VChart/Areas/VChartArea/config.vue
Normal file
@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<!-- vCharts 全局设置 -->
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
<Axis :axis="optionData.xAxis"></Axis>
|
||||
<Axis :axis="optionData.yAxis"></Axis>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting, Axis } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<vChartGlobalThemeJsonType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
16
src/packages/components/VChart/Areas/VChartArea/data.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"values": [
|
||||
{ "type": "Nail polish", "country": "China", "value": 3054 },
|
||||
{ "type": "Nail polish", "country": "USA", "value": 12814 },
|
||||
{ "type": "Eyebrow pencil", "country": "China", "value": 5067 },
|
||||
{ "type": "Eyebrow pencil", "country": "USA", "value": 13012 },
|
||||
{ "type": "Rouge", "country": "China", "value": 7004 },
|
||||
{ "type": "Rouge", "country": "USA", "value": 11624 },
|
||||
{ "type": "Lipstick", "country": "China", "value": 9054 },
|
||||
{ "type": "Lipstick", "country": "USA", "value": 8814 },
|
||||
{ "type": "Eyeshadows", "country": "China", "value": 12043 },
|
||||
{ "type": "Eyeshadows", "country": "USA", "value": 12998 },
|
||||
{ "type": "Eyeliner", "country": "China", "value": 15067 },
|
||||
{ "type": "Eyeliner", "country": "USA", "value": 12321 }
|
||||
]
|
||||
}
|
14
src/packages/components/VChart/Areas/VChartArea/index.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const VChartAreaConfig: ConfigType = {
|
||||
key: 'VChartArea',
|
||||
chartKey: 'VVChartArea',
|
||||
conKey: 'VCVChartArea',
|
||||
title: 'VChart面积图',
|
||||
category: ChatCategoryEnum.AREA,
|
||||
categoryName: ChatCategoryEnumName.AREA,
|
||||
package: PackagesCategoryEnum.VCHART,
|
||||
chartFrame: ChartFrameEnum.VCHART,
|
||||
image: 'vchart_area.png'
|
||||
}
|
22
src/packages/components/VChart/Areas/VChartArea/index.vue
Normal file
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<GoVChart ref="vChartRef" :option="chartConfig.option"> </GoVChart>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { GoVChart } from '@/components/GoVChart'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import config from './config'
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<config>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||
props.chartConfig.option.dataset = newData
|
||||
})
|
||||
</script>
|
@ -0,0 +1,48 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { VChartPercentAreaConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { vChartOptionPrefixHandle } from '@/packages/public/vChart'
|
||||
import data from './data.json'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import axisThemeJson from '@/settings/vchartThemes/axis.theme.json'
|
||||
import { IAreaOption } from '../../index.d'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
export const option: IAreaOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'area',
|
||||
dataset: data,
|
||||
xField: 'type',
|
||||
yField: 'value',
|
||||
seriesField: 'country',
|
||||
stack: true,
|
||||
percent: true,
|
||||
// 业务配置(后续会被转换为图表spec)
|
||||
category: VChartPercentAreaConfig.category,
|
||||
xAxis: {
|
||||
name: 'x轴',
|
||||
...axisThemeJson,
|
||||
grid: {
|
||||
...axisThemeJson.grid,
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
name: 'y轴',
|
||||
...axisThemeJson,
|
||||
grid: {
|
||||
...axisThemeJson.grid,
|
||||
style: {
|
||||
...axisThemeJson.grid.style,
|
||||
lineDash: [3, 3]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = VChartPercentAreaConfig.key
|
||||
public chartConfig = cloneDeep(VChartPercentAreaConfig)
|
||||
// 图表配置项
|
||||
public option = vChartOptionPrefixHandle(option, includes)
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<!-- vCharts 全局设置 -->
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
<Axis :axis="optionData.xAxis"></Axis>
|
||||
<Axis :axis="optionData.yAxis"></Axis>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting, Axis } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<vChartGlobalThemeJsonType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"values": [
|
||||
{ "type": "Nail polish", "country": "China", "value": 3054 },
|
||||
{ "type": "Nail polish", "country": "USA", "value": 12814 },
|
||||
{ "type": "Eyebrow pencil", "country": "China", "value": 5067 },
|
||||
{ "type": "Eyebrow pencil", "country": "USA", "value": 13012 },
|
||||
{ "type": "Rouge", "country": "China", "value": 7004 },
|
||||
{ "type": "Rouge", "country": "USA", "value": 11624 },
|
||||
{ "type": "Lipstick", "country": "China", "value": 9054 },
|
||||
{ "type": "Lipstick", "country": "USA", "value": 8814 },
|
||||
{ "type": "Eyeshadows", "country": "China", "value": 12043 },
|
||||
{ "type": "Eyeshadows", "country": "USA", "value": 12998 },
|
||||
{ "type": "Eyeliner", "country": "China", "value": 15067 },
|
||||
{ "type": "Eyeliner", "country": "USA", "value": 12321 }
|
||||
]
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const VChartPercentAreaConfig: ConfigType = {
|
||||
key: 'VChartPercentArea',
|
||||
chartKey: 'VVChartPercentArea',
|
||||
conKey: 'VCVChartPercentArea',
|
||||
title: 'VChart百分比面积图',
|
||||
category: ChatCategoryEnum.AREA,
|
||||
categoryName: ChatCategoryEnumName.AREA,
|
||||
package: PackagesCategoryEnum.VCHART,
|
||||
chartFrame: ChartFrameEnum.VCHART,
|
||||
image: 'vchart_percent_area.png'
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<GoVChart ref="vChartRef" :option="chartConfig.option"> </GoVChart>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { GoVChart } from '@/components/GoVChart'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import config from './config'
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<config>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||
props.chartConfig.option.dataset = newData
|
||||
})
|
||||
</script>
|
4
src/packages/components/VChart/Areas/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { VChartAreaConfig } from './VChartArea/index'
|
||||
import { VChartPercentAreaConfig } from './VChartPercentArea/index'
|
||||
|
||||
export default [VChartAreaConfig, VChartPercentAreaConfig]
|
@ -5,7 +5,7 @@ export const VChartBarCommonConfig: ConfigType = {
|
||||
key: 'VChartBarCommon',
|
||||
chartKey: 'VVChartBarCommon',
|
||||
conKey: 'VCVChartBarCommon',
|
||||
title: 'VChart柱状图',
|
||||
title: 'VChart并列柱状图',
|
||||
category: ChatCategoryEnum.BAR,
|
||||
categoryName: ChatCategoryEnumName.BAR,
|
||||
package: PackagesCategoryEnum.VCHART,
|
||||
|
@ -5,7 +5,7 @@ export const VChartBarStackConfig: ConfigType = {
|
||||
key: 'VChartBarStack',
|
||||
chartKey: 'VVChartBarStack',
|
||||
conKey: 'VCVChartBarStack',
|
||||
title: 'VChart柱状图',
|
||||
title: 'VChart堆叠柱状图',
|
||||
category: ChatCategoryEnum.BAR,
|
||||
categoryName: ChatCategoryEnumName.BAR,
|
||||
package: PackagesCategoryEnum.VCHART,
|
||||
|
@ -0,0 +1,25 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { VChartFunnelConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { vChartOptionPrefixHandle } from '@/packages/public/vChart'
|
||||
import data from './data.json'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import { IFunnelOption } from '../../index.d'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
export const option: IFunnelOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'funnel',
|
||||
dataset: data,
|
||||
categoryField: 'name',
|
||||
valueField: 'value',
|
||||
// 业务配置(后续会被转换为图表spec)
|
||||
category: VChartFunnelConfig.category,
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = VChartFunnelConfig.key
|
||||
public chartConfig = cloneDeep(VChartFunnelConfig)
|
||||
// 图表配置项
|
||||
public option = vChartOptionPrefixHandle(option, includes)
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<!-- vCharts 全局设置 -->
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<vChartGlobalThemeJsonType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"value": 100,
|
||||
"name": "Step1"
|
||||
},
|
||||
{
|
||||
"value": 80,
|
||||
"name": "Step2"
|
||||
},
|
||||
{
|
||||
"value": 60,
|
||||
"name": "Step3"
|
||||
},
|
||||
{
|
||||
"value": 40,
|
||||
"name": "Step4"
|
||||
},
|
||||
{
|
||||
"value": 20,
|
||||
"name": "Step5"
|
||||
}
|
||||
]
|
||||
}
|
14
src/packages/components/VChart/Funnels/VChartFunnel/index.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const VChartFunnelConfig: ConfigType = {
|
||||
key: 'VChartFunnel',
|
||||
chartKey: 'VVChartFunnel',
|
||||
conKey: 'VCVChartFunnel',
|
||||
title: 'VChart漏斗图',
|
||||
category: ChatCategoryEnum.FUNNEL,
|
||||
categoryName: ChatCategoryEnumName.FUNNEL,
|
||||
package: PackagesCategoryEnum.VCHART,
|
||||
chartFrame: ChartFrameEnum.VCHART,
|
||||
image: 'vchart_funnel.png'
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<GoVChart ref="vChartRef" :option="chartConfig.option"> </GoVChart>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { GoVChart } from '@/components/GoVChart'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import config from './config'
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<config>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||
props.chartConfig.option.dataset = newData
|
||||
})
|
||||
</script>
|
3
src/packages/components/VChart/Funnels/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { VChartFunnelConfig } from './VChartFunnel/index'
|
||||
|
||||
export default [VChartFunnelConfig]
|
47
src/packages/components/VChart/Lines/VChartLine/config.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { VChartLineConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { vChartOptionPrefixHandle } from '@/packages/public/vChart'
|
||||
import data from './data.json'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import axisThemeJson from '@/settings/vchartThemes/axis.theme.json'
|
||||
import { ILineOption } from '../../index.d'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
export const option: ILineOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'line',
|
||||
dataset: data,
|
||||
xField: 'type',
|
||||
yField: 'value',
|
||||
seriesField: 'country',
|
||||
stack: true,
|
||||
// 业务配置(后续会被转换为图表spec)
|
||||
category: VChartLineConfig.category,
|
||||
xAxis: {
|
||||
name: 'x轴',
|
||||
...axisThemeJson,
|
||||
grid: {
|
||||
...axisThemeJson.grid,
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
name: 'y轴',
|
||||
...axisThemeJson,
|
||||
grid: {
|
||||
...axisThemeJson.grid,
|
||||
style: {
|
||||
...axisThemeJson.grid.style,
|
||||
lineDash: [3, 3]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = VChartLineConfig.key
|
||||
public chartConfig = cloneDeep(VChartLineConfig)
|
||||
// 图表配置项
|
||||
public option = vChartOptionPrefixHandle(option, includes)
|
||||
}
|
19
src/packages/components/VChart/Lines/VChartLine/config.vue
Normal file
@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<!-- vCharts 全局设置 -->
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
<Axis :axis="optionData.xAxis"></Axis>
|
||||
<Axis :axis="optionData.yAxis"></Axis>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting, Axis } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<vChartGlobalThemeJsonType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
16
src/packages/components/VChart/Lines/VChartLine/data.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"values": [
|
||||
{ "type": "Nail polish", "country": "China", "value": 3054 },
|
||||
{ "type": "Nail polish", "country": "USA", "value": 12814 },
|
||||
{ "type": "Eyebrow pencil", "country": "China", "value": 5067 },
|
||||
{ "type": "Eyebrow pencil", "country": "USA", "value": 13012 },
|
||||
{ "type": "Rouge", "country": "China", "value": 7004 },
|
||||
{ "type": "Rouge", "country": "USA", "value": 11624 },
|
||||
{ "type": "Lipstick", "country": "China", "value": 9054 },
|
||||
{ "type": "Lipstick", "country": "USA", "value": 8814 },
|
||||
{ "type": "Eyeshadows", "country": "China", "value": 12043 },
|
||||
{ "type": "Eyeshadows", "country": "USA", "value": 12998 },
|
||||
{ "type": "Eyeliner", "country": "China", "value": 15067 },
|
||||
{ "type": "Eyeliner", "country": "USA", "value": 12321 }
|
||||
]
|
||||
}
|
14
src/packages/components/VChart/Lines/VChartLine/index.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const VChartLineConfig: ConfigType = {
|
||||
key: 'VChartLine',
|
||||
chartKey: 'VVChartLine',
|
||||
conKey: 'VCVChartLine',
|
||||
title: 'VChart折线图',
|
||||
category: ChatCategoryEnum.LINE,
|
||||
categoryName: ChatCategoryEnumName.LINE,
|
||||
package: PackagesCategoryEnum.VCHART,
|
||||
chartFrame: ChartFrameEnum.VCHART,
|
||||
image: 'vchart_line.png'
|
||||
}
|
22
src/packages/components/VChart/Lines/VChartLine/index.vue
Normal file
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<GoVChart ref="vChartRef" :option="chartConfig.option"> </GoVChart>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { GoVChart } from '@/components/GoVChart'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import config from './config'
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<config>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||
props.chartConfig.option.dataset = newData
|
||||
})
|
||||
</script>
|
3
src/packages/components/VChart/Lines/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { VChartLineConfig } from './VChartLine/index'
|
||||
|
||||
export default [VChartLineConfig]
|
26
src/packages/components/VChart/Pies/VChartPie/config.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { VChartPieConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { vChartOptionPrefixHandle } from '@/packages/public/vChart'
|
||||
import data from './data.json'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import { IPieOption } from '../../index.d'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
export const option: IPieOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'pie',
|
||||
dataset: data,
|
||||
categoryField: 'year',
|
||||
valueField: 'value',
|
||||
seriesField: 'year',
|
||||
// 业务配置(后续会被转换为图表spec)
|
||||
category: VChartPieConfig.category,
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = VChartPieConfig.key
|
||||
public chartConfig = cloneDeep(VChartPieConfig)
|
||||
// 图表配置项
|
||||
public option = vChartOptionPrefixHandle(option, includes)
|
||||
}
|
17
src/packages/components/VChart/Pies/VChartPie/config.vue
Normal file
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<!-- vCharts 全局设置 -->
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<vChartGlobalThemeJsonType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
14
src/packages/components/VChart/Pies/VChartPie/data.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"values": [
|
||||
{ "type": "Autocracies", "year": "1930", "value": 129 },
|
||||
{ "type": "Autocracies", "year": "1940", "value": 133 },
|
||||
{ "type": "Autocracies", "year": "1950", "value": 130 },
|
||||
{ "type": "Autocracies", "year": "1960", "value": 126 },
|
||||
{ "type": "Autocracies", "year": "1970", "value": 117 },
|
||||
{ "type": "Autocracies", "year": "1980", "value": 114 },
|
||||
{ "type": "Autocracies", "year": "1990", "value": 111 },
|
||||
{ "type": "Autocracies", "year": "2000", "value": 89 },
|
||||
{ "type": "Autocracies", "year": "2010", "value": 80 },
|
||||
{ "type": "Autocracies", "year": "2018", "value": 80 }
|
||||
]
|
||||
}
|
14
src/packages/components/VChart/Pies/VChartPie/index.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const VChartPieConfig: ConfigType = {
|
||||
key: 'VChartPie',
|
||||
chartKey: 'VVChartPie',
|
||||
conKey: 'VCVChartPie',
|
||||
title: 'VChart饼图',
|
||||
category: ChatCategoryEnum.PIE,
|
||||
categoryName: ChatCategoryEnumName.PIE,
|
||||
package: PackagesCategoryEnum.VCHART,
|
||||
chartFrame: ChartFrameEnum.VCHART,
|
||||
image: 'vchart_pie.png'
|
||||
}
|
22
src/packages/components/VChart/Pies/VChartPie/index.vue
Normal file
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<GoVChart ref="vChartRef" :option="chartConfig.option"> </GoVChart>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { GoVChart } from '@/components/GoVChart'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import config from './config'
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<config>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||
props.chartConfig.option.dataset = newData
|
||||
})
|
||||
</script>
|
3
src/packages/components/VChart/Pies/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { VChartPieConfig } from './VChartPie/index'
|
||||
|
||||
export default [VChartPieConfig]
|
@ -0,0 +1,47 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { VChartScatterConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { vChartOptionPrefixHandle } from '@/packages/public/vChart'
|
||||
import data from './data.json'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import axisThemeJson from '@/settings/vchartThemes/axis.theme.json'
|
||||
import { IAreaOption } from '../../index.d'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
export const option: IAreaOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'scatter',
|
||||
dataset: data,
|
||||
stack: true,
|
||||
xField: 'x',
|
||||
yField: 'horsepower',
|
||||
seriesField: 'cylinders',
|
||||
// 业务配置(后续会被转换为图表spec)
|
||||
category: VChartScatterConfig.category,
|
||||
xAxis: {
|
||||
name: 'x轴',
|
||||
...axisThemeJson,
|
||||
grid: {
|
||||
...axisThemeJson.grid,
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
name: 'y轴',
|
||||
...axisThemeJson,
|
||||
grid: {
|
||||
...axisThemeJson.grid,
|
||||
style: {
|
||||
...axisThemeJson.grid.style,
|
||||
lineDash: [3, 3]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = VChartScatterConfig.key
|
||||
public chartConfig = cloneDeep(VChartScatterConfig)
|
||||
// 图表配置项
|
||||
public option = vChartOptionPrefixHandle(option, includes)
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<!-- vCharts 全局设置 -->
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
<Axis :axis="optionData.xAxis"></Axis>
|
||||
<Axis :axis="optionData.yAxis"></Axis>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting, Axis } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<vChartGlobalThemeJsonType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
2846
src/packages/components/VChart/Scatters/VChartScatter/data.json
Normal file
@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const VChartScatterConfig: ConfigType = {
|
||||
key: 'VChartScatter',
|
||||
chartKey: 'VVChartScatter',
|
||||
conKey: 'VCVChartScatter',
|
||||
title: 'VChart散点图',
|
||||
category: ChatCategoryEnum.SCATTER,
|
||||
categoryName: ChatCategoryEnumName.SCATTER,
|
||||
package: PackagesCategoryEnum.VCHART,
|
||||
chartFrame: ChartFrameEnum.VCHART,
|
||||
image: 'vchart_scatter.png'
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<GoVChart ref="vChartRef" :option="chartConfig.option"> </GoVChart>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { GoVChart } from '@/components/GoVChart'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import config from './config'
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<config>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||
props.chartConfig.option.dataset = newData
|
||||
})
|
||||
</script>
|
3
src/packages/components/VChart/Scatters/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { VChartScatterConfig } from './VChartScatter/index'
|
||||
|
||||
export default [VChartScatterConfig]
|
@ -0,0 +1,26 @@
|
||||
import { PublicConfigClass } from '@/packages/public'
|
||||
import { VChartWordCloudConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { vChartOptionPrefixHandle } from '@/packages/public/vChart'
|
||||
import data from './data.json'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import { IWordCloudOption } from '../../index.d'
|
||||
|
||||
export const includes = ['legends', 'tooltip']
|
||||
export const option: IWordCloudOption & { dataset?: any } = {
|
||||
// 图表配置
|
||||
type: 'wordCloud',
|
||||
dataset: data,
|
||||
nameField: 'name',
|
||||
valueField: 'value',
|
||||
seriesField: 'name',
|
||||
// 业务配置(后续会被转换为图表spec)
|
||||
category: VChartWordCloudConfig.category,
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = VChartWordCloudConfig.key
|
||||
public chartConfig = cloneDeep(VChartWordCloudConfig)
|
||||
// 图表配置项
|
||||
public option = vChartOptionPrefixHandle(option, includes)
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<!-- vCharts 全局设置 -->
|
||||
<VChartGlobalSetting :optionData="optionData"></VChartGlobalSetting>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { VChartGlobalSetting } from '@/components/Pages/VChartItemSetting'
|
||||
import { vChartGlobalThemeJsonType } from '@/settings/vchartThemes/index'
|
||||
|
||||
defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<vChartGlobalThemeJsonType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
@ -0,0 +1,88 @@
|
||||
{
|
||||
"values": [
|
||||
{
|
||||
"name": "数据可视化",
|
||||
"value": 8000
|
||||
},
|
||||
{
|
||||
"name": "GO VIEW",
|
||||
"value": 6181
|
||||
},
|
||||
{
|
||||
"name": "低代码",
|
||||
"value": 4386
|
||||
},
|
||||
{
|
||||
"name": "Vue3",
|
||||
"value": 4055
|
||||
},
|
||||
{
|
||||
"name": "TypeScript4",
|
||||
"value": 2467
|
||||
},
|
||||
{
|
||||
"name": "Vite2",
|
||||
"value": 2244
|
||||
},
|
||||
{
|
||||
"name": "NaiveUI",
|
||||
"value": 1898
|
||||
},
|
||||
{
|
||||
"name": "ECharts5",
|
||||
"value": 1484
|
||||
},
|
||||
{
|
||||
"name": "VChart",
|
||||
"value": 600
|
||||
},
|
||||
{
|
||||
"name": "Axios",
|
||||
"value": 1112
|
||||
},
|
||||
{
|
||||
"name": "Pinia2",
|
||||
"value": 965
|
||||
},
|
||||
{
|
||||
"name": "PlopJS",
|
||||
"value": 847
|
||||
},
|
||||
{
|
||||
"name": "sfc",
|
||||
"value": 582
|
||||
},
|
||||
{
|
||||
"name": "SCSS",
|
||||
"value": 555
|
||||
},
|
||||
{
|
||||
"name": "pnpm",
|
||||
"value": 550
|
||||
},
|
||||
{
|
||||
"name": "eslint",
|
||||
"value": 462
|
||||
},
|
||||
{
|
||||
"name": "json",
|
||||
"value": 366
|
||||
},
|
||||
{
|
||||
"name": "图表",
|
||||
"value": 360
|
||||
},
|
||||
{
|
||||
"name": "地图",
|
||||
"value": 282
|
||||
},
|
||||
{
|
||||
"name": "时钟",
|
||||
"value": 273
|
||||
},
|
||||
{
|
||||
"name": "标题",
|
||||
"value": 265
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const VChartWordCloudConfig: ConfigType = {
|
||||
key: 'VChartWordCloud',
|
||||
chartKey: 'VVChartWordCloud',
|
||||
conKey: 'VCVChartWordCloud',
|
||||
title: 'VChart词云图',
|
||||
category: ChatCategoryEnum.WORDCLOUD,
|
||||
categoryName: ChatCategoryEnumName.WORDCLOUD,
|
||||
package: PackagesCategoryEnum.VCHART,
|
||||
chartFrame: ChartFrameEnum.VCHART,
|
||||
image: 'vchart_word_cloud.png'
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<GoVChart ref="vChartRef" :option="chartConfig.option"> </GoVChart>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { GoVChart } from '@/components/GoVChart'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import config from './config'
|
||||
|
||||
const props = defineProps({
|
||||
chartConfig: {
|
||||
type: Object as PropType<config>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
||||
props.chartConfig.option.dataset = newData
|
||||
})
|
||||
</script>
|
3
src/packages/components/VChart/WordClouds/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { VChartWordCloudConfig } from './VChartWordCloud/index'
|
||||
|
||||
export default [VChartWordCloudConfig]
|
64
src/packages/components/VChart/index.d.ts
vendored
@ -1,13 +1,25 @@
|
||||
import { IBarChartSpec } from '@visactor/vchart'
|
||||
import { IBarChartSpec, ILineChartSpec, IAreaChartSpec, IPieChartSpec, IFunnelChartSpec, IWordCloudChartSpec } from '@visactor/vchart'
|
||||
import { ICartesianAxisCommonSpec } from '@visactor/vchart/esm/component/axis'
|
||||
|
||||
|
||||
export enum ChatCategoryEnum {
|
||||
BAR = 'Bars',
|
||||
PIE = 'Pies',
|
||||
LINE = 'Lines',
|
||||
AREA = 'Areas',
|
||||
FUNNEL = 'Funnels',
|
||||
WORDCLOUD = 'WordClouds',
|
||||
SCATTER = 'Scatters',
|
||||
}
|
||||
|
||||
export enum ChatCategoryEnumName {
|
||||
BAR = '柱状图',
|
||||
PIE = '饼图',
|
||||
LINE = '折线图',
|
||||
AREA = '面积图',
|
||||
FUNNEL = '漏斗图',
|
||||
WORDCLOUD = '词云图',
|
||||
SCATTER = '散点图',
|
||||
}
|
||||
|
||||
export interface IBarOption extends Omit<IBarChartSpec, 'axes'> {
|
||||
@ -21,6 +33,54 @@ export interface IBarOption extends Omit<IBarChartSpec, 'axes'> {
|
||||
} & ICartesianAxisCommonSpec
|
||||
}
|
||||
|
||||
export interface ILineOption extends Omit<ILineChartSpec, 'axes'> {
|
||||
category: ChatCategoryEnum.LINE
|
||||
type: 'line'
|
||||
xAxis?: {
|
||||
name: string
|
||||
} & ICartesianAxisCommonSpec
|
||||
yAxis?: {
|
||||
name: string
|
||||
} & ICartesianAxisCommonSpec
|
||||
}
|
||||
|
||||
export interface IAreaOption extends Omit<IAreaChartSpec, 'axes'> {
|
||||
category: ChatCategoryEnum.AREA
|
||||
type: 'area'
|
||||
xAxis?: {
|
||||
name: string
|
||||
} & ICartesianAxisCommonSpec
|
||||
yAxis?: {
|
||||
name: string
|
||||
} & ICartesianAxisCommonSpec
|
||||
}
|
||||
|
||||
export interface IPieOption extends IPieChartSpec {
|
||||
category: ChatCategoryEnum.PIE
|
||||
type: 'pie'
|
||||
}
|
||||
|
||||
export interface IFunnelOption extends IFunnelChartSpec {
|
||||
category: ChatCategoryEnum.FUNNEL
|
||||
type: 'funnel'
|
||||
}
|
||||
|
||||
export interface IWordCloudOption extends IWordCloudChartSpec {
|
||||
category: ChatCategoryEnum.WORDCLOUD
|
||||
type: 'wordCloud'
|
||||
}
|
||||
|
||||
export interface IScatterOption extends Omit<IAreaChartSpec, 'axes'> {
|
||||
category: ChatCategoryEnum.SCATTER
|
||||
type: 'scatter'
|
||||
xAxis?: {
|
||||
name: string
|
||||
} & ICartesianAxisCommonSpec
|
||||
yAxis?: {
|
||||
name: string
|
||||
} & ICartesianAxisCommonSpec
|
||||
}
|
||||
|
||||
// todo
|
||||
// export type IOption = IBarOption | ILineOption ....
|
||||
export type IOption = IBarOption
|
||||
export type IOption = IBarOption | IPieOption | ILineOption | IAreaOption | IFunnelOption | IScatterOption
|
||||
|
@ -1,3 +1,9 @@
|
||||
import Bars from './Bars'
|
||||
import Pies from './Pies'
|
||||
import Lines from './Lines'
|
||||
import Areas from './Areas'
|
||||
import Funnels from './Funnels'
|
||||
import WordClouds from './WordClouds'
|
||||
import Scatters from './Scatters'
|
||||
|
||||
export const VChartList = [...Bars]
|
||||
export const VChartList = [...Bars, ...Pies, ...Lines, ...Areas, ...Funnels, ...WordClouds, ...Scatters]
|
||||
|