You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
4.5 KiB

4 months ago
import type { ID, State } from '../types';
import type { ComboStyle } from './element/combo';
import type { EdgeStyle } from './element/edge';
import type { NodeStyle } from './element/node';
/**
* <zh/>
*
* <en/> Graph data
* @remarks
* <zh/> GraphData Graph
*
* <zh/>
*
* <en/> Graph data is one of the data types received by Graph, which contains a collection of nodes, edges, and combos.
*
* <en/> An example of a graph data is as follows:
*
* ```json
* {
* "nodes": [
* { "id": "node1", "combo": "combo-1", "style": { "x": 100, "y": 100 } },
* { "id": "node2", "style": { "x": 200, "y": 200 } }
* ],
* "edges": [{ "source": "node1", "target": "node2" }],
* "combos": [{ "id": "combo-1", "style": { "x": 100, "y": 100 } }]
* }
* ```
*/
export interface GraphData {
/**
* <zh/>
*
* <en/> node data
*/
nodes?: NodeData[];
/**
* <zh/>
*
* <en/> edge data
*/
edges?: EdgeData[];
/**
* <zh/> Combo
*
* <en/> combo data
*/
combos?: ComboData[];
}
/**
* <zh/>
*
* <en/> Node data
*/
export interface NodeData {
/**
* <zh/> ID
*
* <en/> Node ID
*/
id: ID;
/**
* <zh/>
*
* <en/> Node type
*/
type?: string;
/**
* <zh/>
*
* <en/> Node data
* @remarks
* <zh/>
*
* <en/> Used to store custom data of the node, which can be obtained through callback functions in the style mapping
*/
data?: Record<string, unknown>;
/**
* <zh/>
*
* <en/> Node style
*/
style?: NodeStyle;
/**
* <zh/>
*
* <en/> Initial state of the node
*/
states?: State[];
/**
* <zh/> ID
*
* <en/> ID of the combo to which the node belongs
*/
combo?: ID | null;
/**
* <zh/> ID
*
* <en/> Child node ID
* @remarks
* <zh/>
*
* <en/> Suitable for tree graph structure
*/
children?: ID[];
/**
* <zh/>
*
* <en/> Node depth
* @remarks
* <zh/>
*
* <en/> Suitable for tree graph structure
*/
depth?: number;
[key: string]: unknown;
}
/**
* <zh/>
*
* <en/> Combo data
*/
export interface ComboData {
/**
* <zh/> Combo ID
*
* <en/> Combo ID
*/
id: ID;
/**
* <zh/> Combo
*
* <en/> Combo type
*/
type?: string;
/**
* <zh/> Combo
*
* <en/> Combo data
* @remarks
* <zh/> Combo
*
* <en/> Used to store custom data of the Combo, which can be obtained through callback functions in the style mapping
*/
data?: Record<string, unknown>;
/**
* <zh/> Combo
*
* <en/> Combo style
*/
style?: ComboStyle;
/**
* <zh/>
*
* <en/> Initial state of the combo
*/
states?: State[];
/**
* <zh/> ID
*
* <en/> ID of the combo to which the combo belongs
*/
combo?: ID | null;
[key: string]: unknown;
}
/**
* <zh/>
*
* <en/> Edge data
*/
export interface EdgeData {
/**
* <zh/> ID
*
* <en/> Edge ID
*/
id?: ID;
/**
* <zh/> ID
*
* <en/> Source node ID
*/
source: ID;
/**
* <zh/> ID
*
* <en/> Target node ID
*/
target: ID;
/**
* <zh/>
*
* <en/> Edge type
*/
type?: string;
/**
* <zh/>
*
* <en/> Edge data
* @remarks
* <zh/>
*
* <en/> Used to store custom data of the edge, which can be obtained through callback functions in the style mapping
*/
data?: Record<string, unknown>;
/**
* <zh/>
*
* <en/> Edge style
*/
style?: EdgeStyle;
/**
* <zh/>
*
* <en/> Initial state of the edge
*/
states?: State[];
[key: string]: unknown;
}