mirror of
https://gitee.com/dromara/go-view.git
synced 2024-11-30 10:48:40 +08:00
!203 feat: 增加关系图力引导布局逻辑
Merge pull request !203 from QuietlyChan/feat-graph
This commit is contained in:
commit
e090e669c4
@ -9,13 +9,14 @@ export const includes = []
|
|||||||
// 关系图布局
|
// 关系图布局
|
||||||
export const GraphLayout = [
|
export const GraphLayout = [
|
||||||
{ label: '无', value: 'none' },
|
{ label: '无', value: 'none' },
|
||||||
{ label: '环形', value: 'circular' }
|
{ label: '环形', value: 'circular' },
|
||||||
|
{ label: '力引导', value: 'force' }
|
||||||
]
|
]
|
||||||
|
|
||||||
// 标签开关
|
// 标签开关
|
||||||
export const LabelSwitch = [
|
export const LabelSwitch = [
|
||||||
{ label: '开启', value: 1 },
|
{ label: '开启', value: true },
|
||||||
{ label: '关闭', value: 0 }
|
{ label: '关闭', value: false }
|
||||||
]
|
]
|
||||||
|
|
||||||
// 标签位置
|
// 标签位置
|
||||||
@ -24,44 +25,57 @@ export const LabelPosition = [
|
|||||||
{ label: '右侧', value: 'right' },
|
{ label: '右侧', value: 'right' },
|
||||||
{ label: '顶部', value: 'top' },
|
{ label: '顶部', value: 'top' },
|
||||||
{ label: '底部', value: 'bottom' },
|
{ label: '底部', value: 'bottom' },
|
||||||
{ label: '内部', value: 'inside' },
|
{ label: '内部', value: 'inside' }
|
||||||
|
]
|
||||||
|
|
||||||
|
// 图-迭代动画
|
||||||
|
export const LayoutAnimation = [
|
||||||
|
{ label: '开启', value: true },
|
||||||
|
{ label: '关闭', value: false }
|
||||||
]
|
]
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
dataset: { ...dataJson },
|
dataset: { ...dataJson },
|
||||||
tooltip: {},
|
tooltip: {},
|
||||||
legend:{
|
legend: {
|
||||||
show:true,
|
show: true,
|
||||||
textStyle:{
|
textStyle: {
|
||||||
color:"#eee",
|
color: '#eee',
|
||||||
fontSize: 14 ,
|
fontSize: 14
|
||||||
},
|
|
||||||
data: dataJson.categories.map(function (a) {
|
|
||||||
return a.name;
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
series: [
|
data: dataJson.categories.map(function (a) {
|
||||||
{
|
return a.name
|
||||||
type: 'graph',
|
})
|
||||||
layout: 'none', // none circular环形布局
|
},
|
||||||
data: dataJson.nodes,
|
series: [
|
||||||
links: dataJson.links,
|
{
|
||||||
categories: dataJson.categories,
|
type: 'graph',
|
||||||
label: { // 标签
|
layout: 'none', // none circular环形布局
|
||||||
show: 1,
|
data: dataJson.nodes,
|
||||||
position: 'right',
|
links: dataJson.links,
|
||||||
formatter: '{b}'
|
categories: dataJson.categories,
|
||||||
},
|
label: {
|
||||||
labelLayout: {
|
show: true,
|
||||||
hideOverlap: true
|
position: 'right',
|
||||||
},
|
formatter: '{b}'
|
||||||
lineStyle: {
|
},
|
||||||
color: 'source', // 线条颜色
|
labelLayout: {
|
||||||
curveness: 0.2 // 线条卷曲程度
|
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 {
|
export default class Config extends PublicConfigClass implements CreateComponentType {
|
||||||
public key = GraphConfig.key
|
public key = GraphConfig.key
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
</SettingItemBox>
|
</SettingItemBox>
|
||||||
<SettingItemBox name="线条">
|
<SettingItemBox name="线条">
|
||||||
<SettingItem name="弧线">
|
<SettingItem name="弧线">
|
||||||
<!-- 需要输入两位的小数才会变化 -->
|
<!-- 需要输入两位的小数才会变化 -->
|
||||||
<n-input-number
|
<n-input-number
|
||||||
v-model:value="optionData.series[0].lineStyle.curveness"
|
v-model:value="optionData.series[0].lineStyle.curveness"
|
||||||
:min="0"
|
:min="0"
|
||||||
:step="0.01"
|
:step="0.01"
|
||||||
placeholder="弯曲程度"
|
placeholder="弯曲程度"
|
||||||
size="small"
|
size="small"
|
||||||
></n-input-number>
|
></n-input-number>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
</SettingItemBox>
|
</SettingItemBox>
|
||||||
<SettingItemBox name="图例">
|
<SettingItemBox name="图例">
|
||||||
@ -32,10 +32,61 @@
|
|||||||
size="small"
|
size="small"
|
||||||
:modes="['hex']"
|
:modes="['hex']"
|
||||||
v-model:value="optionData.legend.textStyle.color"
|
v-model:value="optionData.legend.textStyle.color"
|
||||||
></n-color-picker>
|
></n-color-picker>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem name="文本">
|
<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>
|
</n-input-number>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
</SettingItemBox>
|
</SettingItemBox>
|
||||||
@ -46,7 +97,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PropType, computed } from 'vue'
|
import { PropType, computed } from 'vue'
|
||||||
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
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'
|
import { GlobalThemeJsonType } from '@/settings/chartThemes/index'
|
||||||
|
|
||||||
const props = defineProps({
|
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]
|
return props.optionData.series[0]
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<template>
|
<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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
@ -8,4 +8,14 @@ import { DialConfig } from './Dial/index'
|
|||||||
import { SankeyConfig } from './Sankey/index'
|
import { SankeyConfig } from './Sankey/index'
|
||||||
import { GraphConfig } from './Graph/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