Donut
Previous
Diamond
Next
Ellipse
Loading...
The donut node is a ring-shaped geometric figure composed of two concentric circles.
Applicable scenarios:
Used to represent proportional data, such as completion progress and ratio analysis.
Suitable for representing multi-layered data, such as nested ring charts.
Commonly used in data visualization, dashboards, progress charts, etc.
createGraph({autoFit: 'center',data: {nodes: [{id: 'node1',style: {fill: 'transparent',size: 60,donuts: [30, 30, 20, 20],donutPalette: ['#1783FF', '#00C9C9', '#F08F56', '#D580FF'],},},],},node: { type: 'donut' },plugins: [{ type: 'grid-line', size: 30 }],},{ width: 600, height: 220 },(gui, graph) => {gui.add({ type: 'donut' }, 'type').disable();const options = {size: 60,innerR: 50,donutPalette: ['#1783FF', '#00C9C9', '#F08F56', '#D580FF'],};const optionFolder = gui.addFolder('donut.style');optionFolder.add(options, 'size', 0, 100, 1);optionFolder.add(options, 'innerR', 0, 100, 1).name('innerR(%)');optionFolder.add(options, 'donutPalette', ['spectral', 'tableau', ['#1783FF', '#00C9C9', '#F08F56', '#D580FF']]);optionFolder.onChange(({ property, value }) => {if (property === 'innerR') value = value + '%';graph.updateNodeData([{ id: 'node1', style: { [property]: value } }]);graph.render();});},);
设置 node.type
为 donut
以使用甜甜圈节点。
If the element has specific attributes, we will list them below. For all general style attributes, see BaseNode
Attribute | Description | Type | Default | Required |
---|---|---|---|---|
donutFill | Fill color | string | #1783FF | |
donutFillOpacity | Fill color opacity | number | string | 1 | |
donutLineCap | Stroke end style | round | square | butt | butt | |
donutLineDash | Stroke dash style | number[] | - | |
donutLineDashOffset | Stroke dash offset | number | - | |
donutLineJoin | Stroke join style | round | bevel | miter | miter | |
donutLineWidth | Stroke width | number | 1 | |
donutOpacity | Opacity | number | string | 1 | |
donutPalette | Color or palette name | string | string[] | tableau | |
donuts | Donut data | number[] | DonutRound[] | - | |
donutShadowBlur | Shadow blur | number | - | |
donutShadowColor | Shadow color | string | - | |
donutShadowOffsetX | Shadow offset in x-axis direction | number | string | - | |
donutShadowOffsetY | Shadow offset in y-axis direction | number | string | - | |
donutShadowType | Shadow type | inner | outer | outer | |
donutStroke | Stroke color | string | #000 | |
donutStrokeOpacity | Stroke color opacity | number | string | 1 | |
donutVisibility | Visibility of the shape | visible | hidden | visible | |
innerR | Inner ring radius, percentage or px | string | number | 50% |
Attribute | Description | Type | Default | Required |
---|---|---|---|---|
color | Color | string | - | |
fill | Fill color | string | #1783FF | |
fillOpacity | Fill color opacity | number | string | 1 | |
lineCap | Stroke end style | round | square | butt | butt | |
lineDash | Stroke dash style | number[] | - | |
lineDashOffset | Stroke dash offset | number | - | |
lineJoin | Stroke join style | round | bevel | miter | miter | |
lineWidth | Stroke width | number | 1 | |
opacity | Opacity | number | string | 1 | |
shadowBlur | Shadow blur | number | - | |
shadowColor | Shadow color | string | - | |
shadowOffsetX | Shadow offset in x-axis direction | number | string | - | |
shadowOffsetY | Shadow offset in y-axis direction | number | string | - | |
shadowType | Shadow type | inner | outer | outer | |
stroke | Stroke color | string | #000 | |
strokeOpacity | Stroke color opacity | number | string | 1 | |
value | Value for ratio calculation | number | - | ✓ |
visibility | Visibility of the shape | visible | hidden | visible |