| @@ -1,19 +1,19 @@ | |||||
| import { Flex } from 'antd'; | import { Flex } from 'antd'; | ||||
| import styles from './index.less'; | import styles from './index.less'; | ||||
| type GraphLegandData = { | |||||
| type GraphLegendData = { | |||||
| name: string; | name: string; | ||||
| color: string; | color: string; | ||||
| radius: number; | |||||
| radius: number | string; | |||||
| fill: boolean; | fill: boolean; | ||||
| }; | }; | ||||
| type GraphLegandProps = { | |||||
| type GraphLegendProps = { | |||||
| style?: React.CSSProperties; | style?: React.CSSProperties; | ||||
| }; | }; | ||||
| function GraphLegand({ style }: GraphLegandProps) { | |||||
| const legends: GraphLegandData[] = [ | |||||
| function GraphLegend({ style }: GraphLegendProps) { | |||||
| const legends: GraphLegendData[] = [ | |||||
| { | { | ||||
| name: '父模型', | name: '父模型', | ||||
| color: 'linear-gradient(305deg,#43c9b1 0%,#93dfd1 100%)', | color: 'linear-gradient(305deg,#43c9b1 0%,#93dfd1 100%)', | ||||
| @@ -32,6 +32,24 @@ function GraphLegand({ style }: GraphLegandProps) { | |||||
| radius: 2, | radius: 2, | ||||
| fill: true, | fill: true, | ||||
| }, | }, | ||||
| { | |||||
| name: '训练数据集', | |||||
| color: '#a5d878', | |||||
| radius: '50%', | |||||
| fill: true, | |||||
| }, | |||||
| { | |||||
| name: '测试数据集', | |||||
| color: '#d8b578', | |||||
| radius: '50%', | |||||
| fill: true, | |||||
| }, | |||||
| { | |||||
| name: '项目', | |||||
| color: 'linear-gradient(305deg,#8981ff 0%,#b3a9ff 100%)', | |||||
| radius: 6, | |||||
| fill: true, | |||||
| }, | |||||
| ]; | ]; | ||||
| return ( | return ( | ||||
| <Flex align="center" className={styles['graph-legend']} style={style}> | <Flex align="center" className={styles['graph-legend']} style={style}> | ||||
| @@ -52,4 +70,4 @@ function GraphLegand({ style }: GraphLegandProps) { | |||||
| ); | ); | ||||
| } | } | ||||
| export default GraphLegand; | |||||
| export default GraphLegend; | |||||
| @@ -8,7 +8,7 @@ import G6, { G6GraphEvent, Graph, Item } from '@antv/g6'; | |||||
| import { ResourceInfoTabKeys } from '@/pages/Dataset/components/ResourceIntro'; | import { ResourceInfoTabKeys } from '@/pages/Dataset/components/ResourceIntro'; | ||||
| import { Flex, Select } from 'antd'; | import { Flex, Select } from 'antd'; | ||||
| import { useEffect, useRef, useState } from 'react'; | import { useEffect, useRef, useState } from 'react'; | ||||
| import GraphLegand from '../GraphLegand'; | |||||
| import GraphLegend from '../GraphLegend'; | |||||
| import NodeTooltips from '../NodeTooltips'; | import NodeTooltips from '../NodeTooltips'; | ||||
| import styles from './index.less'; | import styles from './index.less'; | ||||
| import type { ModelDepsData, ProjectDependency, TrainDataset } from './utils'; | import type { ModelDepsData, ProjectDependency, TrainDataset } from './utils'; | ||||
| @@ -41,16 +41,16 @@ function ModelEvolution({ | |||||
| useEffect(() => { | useEffect(() => { | ||||
| initGraph(); | initGraph(); | ||||
| const changSize = () => { | |||||
| const changeSize = () => { | |||||
| if (!graph || graph.get('destroyed')) return; | if (!graph || graph.get('destroyed')) return; | ||||
| if (!graphRef.current) return; | if (!graphRef.current) return; | ||||
| graph.changeSize(graphRef.current.clientWidth, graphRef.current.clientHeight); | graph.changeSize(graphRef.current.clientWidth, graphRef.current.clientHeight); | ||||
| graph.fitView(); | graph.fitView(); | ||||
| }; | }; | ||||
| window.addEventListener('resize', changSize); | |||||
| window.addEventListener('resize', changeSize); | |||||
| return () => { | return () => { | ||||
| window.removeEventListener('resize', changSize); | |||||
| window.removeEventListener('resize', changeSize); | |||||
| }; | }; | ||||
| }, []); | }, []); | ||||
| @@ -158,7 +158,7 @@ function ModelEvolution({ | |||||
| setHoverNodeData(model); | setHoverNodeData(model); | ||||
| setNodeToolTipX(point.x + offsetX); | setNodeToolTipX(point.x + offsetX); | ||||
| // 92: 版本选择器的高度,296: tooltip的高度 | |||||
| // 92: 版本选择器的高度,296: tooltip 的高度 | |||||
| setNodeToolTipY(point.y + 92 - 296 - offsetY); | setNodeToolTipY(point.y + 92 - 296 - offsetY); | ||||
| setShowNodeTooltip(true); | setShowNodeTooltip(true); | ||||
| }); | }); | ||||
| @@ -258,7 +258,7 @@ function ModelEvolution({ | |||||
| onChange={onVersionChange} | onChange={onVersionChange} | ||||
| options={versionList} | options={versionList} | ||||
| /> | /> | ||||
| <GraphLegand style={{ marginRight: 0, marginLeft: 'auto' }}></GraphLegand> | |||||
| <GraphLegend style={{ marginRight: 0, marginLeft: 'auto' }}></GraphLegend> | |||||
| </Flex> | </Flex> | ||||
| <div className={styles['model-evolution__graph']} id="canvas" ref={graphRef}></div> | <div className={styles['model-evolution__graph']} id="canvas" ref={graphRef}></div> | ||||
| {(showNodeTooltip || enterTooltip) && ( | {(showNodeTooltip || enterTooltip) && ( | ||||
| @@ -92,9 +92,9 @@ export function normalizeChildren(data: ModelDepsData[]) { | |||||
| } | } | ||||
| // 获取 label | // 获取 label | ||||
| export function getLabel(node: { current_model_name: string; version: string }) { | |||||
| export function getLabel(node: ModelDepsData | ModelDepsAPIData) { | |||||
| return ( | return ( | ||||
| fittingString(`${node.current_model_name}`, nodeWidth - 12, 8) + | |||||
| fittingString(`${node.model_version_dependcy_vo.name ?? ''}`, nodeWidth - 12, 8) + | |||||
| '\n' + | '\n' + | ||||
| fittingString(`${node.version}`, nodeWidth - 12, 8) | fittingString(`${node.version}`, nodeWidth - 12, 8) | ||||
| ); | ); | ||||
| @@ -144,10 +144,7 @@ export function normalizeTreeData( | |||||
| normalizedData.model_type = NodeType.current; | normalizedData.model_type = NodeType.current; | ||||
| normalizedData.current_model_name = currentNodeName; | normalizedData.current_model_name = currentNodeName; | ||||
| normalizedData.id = `$M_${normalizedData.current_model_id}_${normalizedData.version}`; | normalizedData.id = `$M_${normalizedData.current_model_id}_${normalizedData.version}`; | ||||
| normalizedData.label = getLabel({ | |||||
| current_model_name: currentNodeName, | |||||
| version: normalizedData.version, | |||||
| }); | |||||
| normalizedData.label = getLabel(normalizedData); | |||||
| normalizedData.style = getStyle(NodeType.current); | normalizedData.style = getStyle(NodeType.current); | ||||
| // let first1 = { ...normalizedData.children[0] }; | // let first1 = { ...normalizedData.children[0] }; | ||||
| // let first2 = { ...normalizedData.children[0] }; | // let first2 = { ...normalizedData.children[0] }; | ||||
| @@ -18,7 +18,7 @@ | |||||
| &__row { | &__row { | ||||
| display: flex; | display: flex; | ||||
| align-items: center; | |||||
| align-items: flex-start; | |||||
| margin: 4px 0; | margin: 4px 0; | ||||
| color: @text-color; | color: @text-color; | ||||
| font-size: 14px; | font-size: 14px; | ||||
| @@ -43,14 +43,12 @@ | |||||
| min-width: 0; | min-width: 0; | ||||
| color: @text-color; | color: @text-color; | ||||
| font-weight: 500; | font-weight: 500; | ||||
| .singleLine(); | |||||
| } | } | ||||
| &__link { | &__link { | ||||
| flex: 1; | flex: 1; | ||||
| min-width: 0; | min-width: 0; | ||||
| font-weight: 500; | font-weight: 500; | ||||
| .singleLine(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -68,7 +68,9 @@ function NodeTooltips({ data, x, y, onMouseEnter, onMouseLeave }: NodeTooltipsPr | |||||
| <a className={styles['node-tooltips__row__link']} onClick={gotoExperimentPage}> | <a className={styles['node-tooltips__row__link']} onClick={gotoExperimentPage}> | ||||
| {data.train_task?.name} | {data.train_task?.name} | ||||
| </a> | </a> | ||||
| ) : null} | |||||
| ) : ( | |||||
| '--' | |||||
| )} | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||