mirror of
https://gitee.com/dromara/go-view.git
synced 2024-11-30 02:38:30 +08:00
!203 feat: 增加关系图力引导布局逻辑
Merge pull request !203 from QuietlyChan/feat-graph
This commit is contained in:
commit
c32a9f7d1b
@ -9,13 +9,14 @@ export const includes = []
|
||||
// 关系图布局
|
||||
export const GraphLayout = [
|
||||
{ label: '无', value: 'none' },
|
||||
{ label: '环形', value: 'circular' }
|
||||
{ label: '环形', value: 'circular' },
|
||||
{ label: '力引导', value: 'force' }
|
||||
]
|
||||
|
||||
// 标签开关
|
||||
export const LabelSwitch = [
|
||||
{ label: '开启', value: 1 },
|
||||
{ label: '关闭', value: 0 }
|
||||
{ label: '开启', value: true },
|
||||
{ label: '关闭', value: false }
|
||||
]
|
||||
|
||||
// 标签位置
|
||||
@ -24,44 +25,57 @@ export const LabelPosition = [
|
||||
{ label: '右侧', value: 'right' },
|
||||
{ label: '顶部', value: 'top' },
|
||||
{ label: '底部', value: 'bottom' },
|
||||
{ label: '内部', value: 'inside' },
|
||||
{ label: '内部', value: 'inside' }
|
||||
]
|
||||
|
||||
// 图-迭代动画
|
||||
export const LayoutAnimation = [
|
||||
{ label: '开启', value: true },
|
||||
{ label: '关闭', value: false }
|
||||
]
|
||||
|
||||
export const option = {
|
||||
dataset: { ...dataJson },
|
||||
tooltip: {},
|
||||
legend:{
|
||||
show:true,
|
||||
textStyle:{
|
||||
color:"#eee",
|
||||
fontSize: 14 ,
|
||||
},
|
||||
data: dataJson.categories.map(function (a) {
|
||||
return a.name;
|
||||
})
|
||||
dataset: { ...dataJson },
|
||||
tooltip: {},
|
||||
legend: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
color: '#eee',
|
||||
fontSize: 14
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'graph',
|
||||
layout: 'none', // none circular环形布局
|
||||
data: dataJson.nodes,
|
||||
links: dataJson.links,
|
||||
categories: dataJson.categories,
|
||||
label: { // 标签
|
||||
show: 1,
|
||||
position: 'right',
|
||||
formatter: '{b}'
|
||||
},
|
||||
labelLayout: {
|
||||
hideOverlap: true
|
||||
},
|
||||
lineStyle: {
|
||||
color: 'source', // 线条颜色
|
||||
curveness: 0.2 // 线条卷曲程度
|
||||
}
|
||||
data: dataJson.categories.map(function (a) {
|
||||
return a.name
|
||||
})
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'graph',
|
||||
layout: 'none', // none circular环形布局
|
||||
data: dataJson.nodes,
|
||||
links: dataJson.links,
|
||||
categories: dataJson.categories,
|
||||
label: {
|
||||
show: true,
|
||||
position: 'right',
|
||||
formatter: '{b}'
|
||||
},
|
||||
labelLayout: {
|
||||
hideOverlap: true
|
||||
},
|
||||
lineStyle: {
|
||||
color: 'source', // 线条颜色
|
||||
curveness: 0.2 // 线条卷曲程度
|
||||
},
|
||||
force: {
|
||||
repulsion: 100,
|
||||
gravity: 0.1,
|
||||
edgeLength: 30,
|
||||
layoutAnimation: true,
|
||||
friction: 0.6
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||
public key = GraphConfig.key
|
||||
|
@ -16,14 +16,14 @@
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="线条">
|
||||
<SettingItem name="弧线">
|
||||
<!-- 需要输入两位的小数才会变化 -->
|
||||
<!-- 需要输入两位的小数才会变化 -->
|
||||
<n-input-number
|
||||
v-model:value="optionData.series[0].lineStyle.curveness"
|
||||
:min="0"
|
||||
:step="0.01"
|
||||
placeholder="弯曲程度"
|
||||
size="small"
|
||||
></n-input-number>
|
||||
v-model:value="optionData.series[0].lineStyle.curveness"
|
||||
:min="0"
|
||||
:step="0.01"
|
||||
placeholder="弯曲程度"
|
||||
size="small"
|
||||
></n-input-number>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="图例">
|
||||
@ -32,10 +32,61 @@
|
||||
size="small"
|
||||
:modes="['hex']"
|
||||
v-model:value="optionData.legend.textStyle.color"
|
||||
></n-color-picker>
|
||||
></n-color-picker>
|
||||
</SettingItem>
|
||||
<SettingItem name="文本">
|
||||
<n-input-number v-model:value="optionData.legend.textStyle.fontSize" :min="0" :step="1" size="small" placeholder="文字大小">
|
||||
<n-input-number
|
||||
v-model:value="optionData.legend.textStyle.fontSize"
|
||||
:min="0"
|
||||
:step="1"
|
||||
size="small"
|
||||
placeholder="文字大小"
|
||||
>
|
||||
</n-input-number>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="力引导" v-show="graphConfig.layout == 'force'">
|
||||
<SettingItem name="斥力因子">
|
||||
<n-input-number
|
||||
v-model:value="optionData.series[0].force.repulsion"
|
||||
:min="0"
|
||||
:step="1"
|
||||
size="small"
|
||||
placeholder="斥力因子大小"
|
||||
>
|
||||
</n-input-number>
|
||||
</SettingItem>
|
||||
<SettingItem name="引力因子">
|
||||
<n-input-number
|
||||
v-model:value="optionData.series[0].force.gravity"
|
||||
:min="0"
|
||||
:step="0.1"
|
||||
size="small"
|
||||
placeholder="引力因子"
|
||||
>
|
||||
</n-input-number>
|
||||
</SettingItem>
|
||||
<SettingItem name="节点距离">
|
||||
<n-input-number
|
||||
v-model:value="optionData.series[0].force.edgeLength"
|
||||
:min="0"
|
||||
:step="1"
|
||||
size="small"
|
||||
placeholder="节点距离"
|
||||
>
|
||||
</n-input-number>
|
||||
</SettingItem>
|
||||
<SettingItem name="迭代动画">
|
||||
<n-select v-model:value="graphConfig.force.layoutAnimation" :options="LayoutAnimation" size="small" />
|
||||
</SettingItem>
|
||||
<SettingItem name="节点速度">
|
||||
<n-input-number
|
||||
v-model:value="optionData.series[0].force.friction"
|
||||
:min="0"
|
||||
:step="0.1"
|
||||
size="small"
|
||||
placeholder="节点速度"
|
||||
>
|
||||
</n-input-number>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
@ -46,7 +97,7 @@
|
||||
<script setup lang="ts">
|
||||
import { PropType, computed } from 'vue'
|
||||
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||
import { option, GraphLayout, LabelSwitch, LabelPosition } from './config'
|
||||
import { option, GraphLayout, LabelSwitch, LabelPosition, LayoutAnimation } from './config'
|
||||
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||
|
||||
const props = defineProps({
|
||||
@ -56,7 +107,7 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const graphConfig = computed<typeof option.series[0]>(() => {
|
||||
const graphConfig = computed<(typeof option.series)[0]>(() => {
|
||||
return props.optionData.series[0]
|
||||
})
|
||||
</script>
|
||||
|
@ -1,5 +1,12 @@
|
||||
<template>
|
||||
<v-chart ref="vChartRef" :init-options="initOptions" :theme="themeColor" :option="option" :manual-update="isPreview()" autoresize></v-chart>
|
||||
<v-chart
|
||||
ref="vChartRef"
|
||||
:init-options="initOptions"
|
||||
:theme="themeColor"
|
||||
:option="option"
|
||||
:manual-update="isPreview()"
|
||||
autoresize
|
||||
></v-chart>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
@ -8,4 +8,14 @@ import { DialConfig } from './Dial/index'
|
||||
import { SankeyConfig } from './Sankey/index'
|
||||
import { GraphConfig } from './Graph/index'
|
||||
|
||||
export default [ProcessConfig, RadarConfig, FunnelConfig, HeatmapConfig, WaterPoloConfig, TreeMapConfig, GraphConfig, SankeyConfig, DialConfig]
|
||||
export default [
|
||||
ProcessConfig,
|
||||
RadarConfig,
|
||||
FunnelConfig,
|
||||
HeatmapConfig,
|
||||
WaterPoloConfig,
|
||||
TreeMapConfig,
|
||||
GraphConfig,
|
||||
SankeyConfig,
|
||||
DialConfig
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user