mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 00:02:51 +08:00
feat: 新增基础树图
This commit is contained in:
parent
62aec195ea
commit
0d1abd00a1
@ -16,6 +16,7 @@ export const heatMapUrl = '/mock/heatMapData'
|
||||
export const scatterBasicUrl = '/mock/scatterBasic'
|
||||
export const mapUrl = '/mock/map'
|
||||
export const wordCloudUrl = '/mock/wordCloud'
|
||||
export const treemapUrl = '/mock/treemap'
|
||||
|
||||
const mockObject: MockMethod[] = [
|
||||
{
|
||||
@ -84,7 +85,12 @@ const mockObject: MockMethod[] = [
|
||||
url: wordCloudUrl,
|
||||
method: RequestHttpEnum.GET,
|
||||
response: () => test.fetchWordCloud
|
||||
}
|
||||
},
|
||||
{
|
||||
url: treemapUrl,
|
||||
method: RequestHttpEnum.GET,
|
||||
response: () => test.fetchTreemap
|
||||
},
|
||||
]
|
||||
|
||||
export default mockObject
|
||||
|
@ -1,6 +1,7 @@
|
||||
import heatmapJson from './heatMapData.json'
|
||||
import scatterJson from './scatter.json'
|
||||
import mapJson from './map.json'
|
||||
import tTreemapJson from './treemap.json'
|
||||
|
||||
export default {
|
||||
// 单图表
|
||||
@ -245,5 +246,12 @@ export default {
|
||||
{ name: '@name', value: '@integer(10, 8000)' },
|
||||
{ name: '@name', value: '@integer(10, 8000)' }
|
||||
]
|
||||
}
|
||||
},
|
||||
// 树图
|
||||
fetchTreemap: {
|
||||
code: 0,
|
||||
status: 200,
|
||||
msg: '请求成功',
|
||||
data: tTreemapJson
|
||||
},
|
||||
}
|
||||
|
50
src/api/mock/treemap.json
Normal file
50
src/api/mock/treemap.json
Normal file
@ -0,0 +1,50 @@
|
||||
[
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 1000)",
|
||||
"children": [
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 500)"
|
||||
},
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 500)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 1000)",
|
||||
"children": [
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 00)"
|
||||
},
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 500)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 1000)",
|
||||
"children": [
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 1000)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 1000)",
|
||||
"children": [
|
||||
{
|
||||
"name": "@name",
|
||||
"value": "@integer(0, 1000)"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,11 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
<global-setting :optionData="optionData"></global-setting>
|
||||
</div>
|
||||
<global-setting :optionData="optionData"></global-setting>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType, computed } from 'vue'
|
||||
import { PropType, computed } from 'vue'
|
||||
import { GlobalSetting } from '@/components/Pages/ChartItemSetting'
|
||||
import { option } from './config'
|
||||
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||
@ -13,12 +11,11 @@ import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||
const props = defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<typeof option & GlobalThemeJsonType>,
|
||||
required: true
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const heatMapConfig = computed<typeof option>(() => {
|
||||
return props.optionData
|
||||
})
|
||||
|
||||
</script>
|
||||
|
27
src/packages/components/Charts/Mores/TreeMap/config.ts
Normal file
27
src/packages/components/Charts/Mores/TreeMap/config.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
|
||||
import { TreeMapConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
import dataJson from './data.json'
|
||||
|
||||
export const includes = []
|
||||
|
||||
export const option = {
|
||||
dataset: dataJson,
|
||||
series: [
|
||||
{
|
||||
name: 'treemap',
|
||||
type: 'treemap',
|
||||
leafDepth: 1,
|
||||
roam: false,
|
||||
data: dataJson
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = TreeMapConfig.key
|
||||
public chartConfig = cloneDeep(TreeMapConfig)
|
||||
// 图表配置项
|
||||
public option = echartOptionProfixHandle(option, includes)
|
||||
}
|
@ -1,6 +1,17 @@
|
||||
<template>
|
||||
<global-setting :optionData="optionData"></global-setting>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { GlobalSetting } from '@/components/Pages/ChartItemSetting'
|
||||
import { option } from './config'
|
||||
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||
|
||||
defineProps({
|
||||
optionData: {
|
||||
type: Object as PropType<typeof option & GlobalThemeJsonType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
50
src/packages/components/Charts/Mores/TreeMap/data.json
Normal file
50
src/packages/components/Charts/Mores/TreeMap/data.json
Normal file
@ -0,0 +1,50 @@
|
||||
[
|
||||
{
|
||||
"name": "nodeA",
|
||||
"value": 10,
|
||||
"children": [
|
||||
{
|
||||
"name": "nodeAa",
|
||||
"value": 4
|
||||
},
|
||||
{
|
||||
"name": "nodeAb",
|
||||
"value": 6
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "nodeA",
|
||||
"value": 10,
|
||||
"children": [
|
||||
{
|
||||
"name": "nodeAa",
|
||||
"value": 4
|
||||
},
|
||||
{
|
||||
"name": "nodeAb",
|
||||
"value": 6
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "nodeB",
|
||||
"value": 20,
|
||||
"children": [
|
||||
{
|
||||
"name": "nodeba",
|
||||
"value": 20
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "nodeC",
|
||||
"value": 20,
|
||||
"children": [
|
||||
{
|
||||
"name": "nodeca",
|
||||
"value": 20
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,5 +1,5 @@
|
||||
import image from '@/assets/images/chart/charts/tree_map.png'
|
||||
import { ConfigType, PackagesCategoryEnum } from '@/packages/index.d'
|
||||
import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d'
|
||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||
|
||||
export const TreeMapConfig: ConfigType = {
|
||||
@ -10,5 +10,6 @@ export const TreeMapConfig: ConfigType = {
|
||||
category: ChatCategoryEnum.MORE,
|
||||
categoryName: ChatCategoryEnumName.MORE,
|
||||
package: PackagesCategoryEnum.CHARTS,
|
||||
chartFrame: ChartFrameEnum.COMMON,
|
||||
image
|
||||
}
|
||||
|
@ -1,13 +1,62 @@
|
||||
<template>
|
||||
<div>
|
||||
水波
|
||||
</div>
|
||||
<v-chart ref="vChartRef" :theme="themeColor" :option="option" :manual-update="isPreview()" autoresize></v-chart>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, PropType, watch } from 'vue'
|
||||
import VChart from 'vue-echarts'
|
||||
import dataJson from './data.json'
|
||||
import { use } from 'echarts/core'
|
||||
import { CanvasRenderer } from 'echarts/renderers'
|
||||
import { TreemapChart } from 'echarts/charts'
|
||||
import { includes } from './config'
|
||||
import { mergeTheme } from '@/packages/public/chart'
|
||||
import { useChartDataFetch } from '@/hooks'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { isPreview } from '@/utils'
|
||||
|
||||
const props = defineProps({
|
||||
themeSetting: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
themeColor: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
chartConfig: {
|
||||
type: Object as PropType<CreateComponentType>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
use([CanvasRenderer, TreemapChart])
|
||||
|
||||
const vChartRef = ref<typeof VChart>()
|
||||
|
||||
const option = computed(() => {
|
||||
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||
})
|
||||
|
||||
const dataSetHandle = (dataset: typeof dataJson) => {
|
||||
if (dataset) {
|
||||
props.chartConfig.option.series[0].data = dataset
|
||||
vChartRef.value?.setOption(props.chartConfig.option)
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
newData => {
|
||||
dataSetHandle(newData)
|
||||
},
|
||||
{
|
||||
deep: false
|
||||
}
|
||||
)
|
||||
|
||||
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: typeof dataJson) => {
|
||||
dataSetHandle(newData)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
@ -75,7 +75,8 @@ import {
|
||||
heatMapUrl,
|
||||
scatterBasicUrl,
|
||||
mapUrl,
|
||||
wordCloudUrl
|
||||
wordCloudUrl,
|
||||
treemapUrl
|
||||
} from '@/api/mock'
|
||||
|
||||
const { HelpOutlineIcon } = icon.ionicons5
|
||||
@ -123,6 +124,9 @@ const apiList = [
|
||||
{
|
||||
value: `【词云】${wordCloudUrl}`
|
||||
},
|
||||
{
|
||||
value: `【树图】${treemapUrl}`
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user