Html
Previous
Hexagon
Next
Image
Loading...
The HTML node is a custom rectangular area used to display HTML content.
Applicable scenarios:
Used to represent complex custom nodes, such as tables, charts, or rich text.
Suitable for representing custom visual elements or interactive components.
Commonly used in custom charts, UI design, etc.
createGraph({data: {nodes: [{id: 'node1',style: {x: 300,y: 110,size: [120, 40],innerHTML: `<div style="width: 100%; height: 100%; background: #7e3feb; display: flex; justify-content: center; align-items: center;"><span style="color: #fff; font-size: 12px;">HTML Node</span></div>`,},},],},node: { type: 'html' },plugins: [{ type: 'grid-line', size: 30 }],},{ width: 600, height: 220 },(gui, graph) => {gui.add({ type: 'html' }, 'type').disable();const options = {size: 50,innerHTML: `<div style="width: 100%; height: 100%; background: #7863FF; display: flex; justify-content: center; align-items: center;"><span style="color: #fff; font-size: 20px;">'HTML Node'</span></div>`,};const optionFolder = gui.addFolder('html.style');optionFolder.add(options, 'size', 0, 100, 1);optionFolder.add(options, 'innerHTML');optionFolder.onChange(({ property, value }) => {graph.updateNodeData([{ id: 'node1', style: { [property]: value } }]);graph.render();});},);
设置 node.type
为 html
以使用 HTML 节点。
If the element has specific attributes, we will list them below. For all general style attributes, see BaseNode
Attribute | Description | Type | Default | Required |
---|---|---|---|---|
dx | Horizontal offset. The HTML container defaults to the top-left corner as the origin, and dx is used for horizontal offset | number | 0 | |
dy | Vertical offset. The HTML container defaults to the top-left corner as the origin, and dy is used for vertical offset | number | 0 | |
innerHTML | HTML content, can be a string or HTMLElement | string | HTMLElement | 0 | ✓ |