Commit e5e438d7 authored by wenmo's avatar wenmo

优化血缘分析

parent c7fc038f
import { Tabs,Empty,Tooltip,Button } from "antd"; import { Tabs,Empty,Tooltip,Button } from "antd";
import { IndentedTreeGraph,DecompositionTreeGraph } from '@ant-design/charts'; import { FlowAnalysisGraph } from '@ant-design/charts';
import {SearchOutlined} from "@ant-design/icons"; import {SearchOutlined} from "@ant-design/icons";
import {StateType} from "@/pages/FlinkSqlStudio/model"; import {StateType} from "@/pages/FlinkSqlStudio/model";
import {connect} from "umi"; import {connect} from "umi";
...@@ -25,44 +25,105 @@ const StudioCA = (props:any) => { ...@@ -25,44 +25,105 @@ const StudioCA = (props:any) => {
}, },
}; };
const buildGraphData=(data,graphData)=>{
if(!graphData.nodes){
graphData.nodes = [];
}
if(!graphData.edges){
graphData.edges = [];
}
for(let i in data){
let nodesItem = {
id:data[i].id,
value:{
title:data[i].name,
items: [
{
text: data[i].columns,
},
],
}
}
graphData.nodes.push(nodesItem);
if(data[i].children){
for(let j in data[i].children){
graphData.edges.push({source: data[i].children[j].id,
target: data[i].id,
value: ''});
buildGraphData(data[i].children,graphData);
}
}
}
};
const config = { const config = {
data:oneTableCAData, data: oneTableCAData,
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-node'], height:350,
bodyStyle: { nodeCfg: {
fill: '#aaa', size: [160, 65],
}, items: {
nodeStateStyles, autoEllipsis: false,
onReady: (graph) => { padding: [10],
graph.on('node:mouseenter', (evt) => { containerStyle: {
const item = evt.item; // fill: '#fff',
graph.setItemState(item, 'hover', true); width:'100px',
}); },
graph.on('node:mouseleave', (evt) => { style: (cfg, group, type) => {
const item = evt.item; const styles = {
graph.setItemState(item, 'hover', false); value: {
}); // fill: '#000',
},
text: {
// fill: '#222',
width:'100px',
},
};
return styles[type];
},
},
nodeStateStyles: {
hover: {
// stroke: '#1890ff',
lineWidth: 2,
},
},
style: {
// fill: '#40a9ff',
// stroke: '#1890ff',
},
}, },
edgeStyle: (item, graph) => { edgeCfg: {
/** type: 'polyline',
* graph.findById(item.target).getModel() label: {
* item.source: 获取 source 数据 style: {
* item.target: 获取 target 数据 // fill: '#666',
*/ fontSize: 12,
/*console.log(item); fillOpacity: 1,
console.log(graph); },
console.log(graph.findById(item.target.id).getModel());*/ },
return { endArrow: {
stroke: '#40a9ff', // fill: '#333',
// lineWidth: graph.findById(item.target).getModel().columnSize, },
lineWidth: 1, edgeStateStyles: {
strokeOpacity: 0.5, hover: {
}; // stroke: '#1890ff',
lineWidth: 2,
},
},
}, },
nodeStyle: () => { markerCfg: (cfg) => {
const { edges } = oneTableCAData;
return { return {
stroke: '#40a9ff', position: 'right',
show: edges.find((item) => item.source === cfg.id),
collapsed: !edges.find((item) => item.source === cfg.id),
}; };
}, },
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-node'],
/*layout: {
rankdir: 'TB',
ranksepFunc: () => 20,
},*/
}; };
const columnConfig = { const columnConfig = {
...@@ -110,7 +171,9 @@ const StudioCA = (props:any) => { ...@@ -110,7 +171,9 @@ const StudioCA = (props:any) => {
}); });
res.then((result)=>{ res.then((result)=>{
if(result.code==0){ if(result.code==0){
setOneTableCAData(fullTreeData(result.datas[0])); let graphData = {};
buildGraphData(result.datas,graphData);
setOneTableCAData(graphData);
}else{ }else{
setOneTableCAData(null); setOneTableCAData(null);
} }
...@@ -124,7 +187,7 @@ const StudioCA = (props:any) => { ...@@ -124,7 +187,7 @@ const StudioCA = (props:any) => {
}); });
res.then((result)=>{ res.then((result)=>{
if(result.code==0){ if(result.code==0){
setOneColumnCAData(fullTreeData(result.datas[0])); setOneColumnCAData(buildGraphData(result.datas[0]));
}else{ }else{
setOneColumnCAData(null); setOneColumnCAData(null);
} }
...@@ -162,7 +225,7 @@ const StudioCA = (props:any) => { ...@@ -162,7 +225,7 @@ const StudioCA = (props:any) => {
/> />
</Tooltip> </Tooltip>
</div> </div>
{oneTableCAData!=null?<IndentedTreeGraph {...config} />:<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />} {oneTableCAData!=null?<FlowAnalysisGraph {...config} />:<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />}
</div> </div>
</TabPane> </TabPane>
{/*<TabPane {/*<TabPane
......
...@@ -541,6 +541,9 @@ export default (): React.ReactNode => { ...@@ -541,6 +541,9 @@ export default (): React.ReactNode => {
<li> <li>
<Link>修改项目名为 Dinky 以及图标</Link> <Link>修改项目名为 Dinky 以及图标</Link>
</li> </li>
<li>
<Link>优化血缘分析图</Link>
</li>
</ul> </ul>
</Paragraph> </Paragraph>
</Timeline.Item> </Timeline.Item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment