@echarts-extension/grid
v0.1.0
Published
ECharts extension chart using the grid graph layout
Downloads
81
Readme
@echarts-extension/grid
Language: English | 中文
ECharts extension chart using a deterministic grid graph layout. Import this package for side effects to register series.type = 'grid'.

Install
npm install echarts @echarts-extension/gridBasic Usage
import * as echarts from 'echarts';
import '@echarts-extension/grid';
const chart = echarts.init(document.getElementById('main'));
chart.setOption({
series: [
{
type: 'grid',
data: [
{ id: 'a', cluster: 'core', value: 8 },
{ id: 'b', cluster: 'core', value: 5 },
{ id: 'c', cluster: 'edge', value: 4 },
{ id: 'd', cluster: 'edge', value: 3 }
],
links: [
{ source: 'a', target: 'b' },
{ source: 'a', target: 'c' }
],
label: { show: true },
layout: {
cols: 2,
preventOverlap: true,
nodeSpacing: 10,
sortBy: 'cluster'
}
}
]
});Data
Use ECharts graph-style input:
dataornodesfor nodes.linksoredgesfor connections.- Each link uses
sourceandtarget, matching a nodeidorname. - When
symbolSizeis omitted, node size is inferred from numericvalue.
Options
This table is generated by scripts/sync-options-from-readmes.mjs --write-readmes. Update the English README option table, then run npm run docs:sync-options to refresh the docs page.
| Option | Description | Values |
| --- | --- | --- |
| type | Registers this package series with ECharts. | 'grid' |
| silent | Disables mouse events for the series when true. | boolean |
| width | Series box width. | number \| string (pixel or percent) |
| height | Series box height. | number \| string (pixel or percent) |
| top | Distance from the top of the chart container. | number \| string (pixel or percent) |
| right | Distance from the right of the chart container. | number \| string (pixel or percent) |
| bottom | Distance from the bottom of the chart container. | number \| string (pixel or percent) |
| left | Distance from the left of the chart container. | number \| string (pixel or percent) |
| data | Graph nodes. Each node may include id, name, value, itemStyle, label, x, y, or size fields. Same effect as nodes. | Array<object \| unknown[]> |
| data.id | Record id. | string \| number |
| data.name | Display name. | string |
| data.value | Numeric value. | number |
| data.itemStyle | Per-record item style. | Object |
| data.itemStyle.color | Fill color. | string |
| data.itemStyle.fill | Alias for fill color. | string |
| data.itemStyle.opacity | Fill opacity. | number |
| data.itemStyle.borderColor | Border color. | string |
| data.itemStyle.borderWidth | Border width. | number |
| data.itemStyle.borderRadius | Corner radius. | number |
| data.itemStyle.shadowBlur | Shadow blur radius. | number |
| data.itemStyle.shadowColor | Shadow color. | string |
| data.itemStyle.lineWidth | Stroke width used by icon or shape styles. | number |
| data.label | Per-record label style. | Object |
| data.label.show | Shows labels when true. | boolean |
| data.label.color | Label text color. | string |
| data.label.fontSize | Label text size. | number |
| data.label.fontWeight | Label font weight. | string \| number |
| data.label.formatter | Formats label text. | string \| function |
| data.x | X coordinate or category. | number |
| data.y | Y coordinate or category. | number |
| data.size | Per-record size. | number |
| nodes | Same effect as data. Graph nodes. Each node may include id, name, value, itemStyle, label, x, y, or size fields. | Array<object \| unknown[]> |
| nodes.id | Record id. | string \| number |
| nodes.name | Display name. | string |
| nodes.value | Numeric value. | number |
| nodes.itemStyle | Per-record item style. | Object |
| nodes.itemStyle.color | Fill color. | string |
| nodes.itemStyle.fill | Alias for fill color. | string |
| nodes.itemStyle.opacity | Fill opacity. | number |
| nodes.itemStyle.borderColor | Border color. | string |
| nodes.itemStyle.borderWidth | Border width. | number |
| nodes.itemStyle.borderRadius | Corner radius. | number |
| nodes.itemStyle.shadowBlur | Shadow blur radius. | number |
| nodes.itemStyle.shadowColor | Shadow color. | string |
| nodes.itemStyle.lineWidth | Stroke width used by icon or shape styles. | number |
| nodes.label | Per-record label style. | Object |
| nodes.label.show | Shows labels when true. | boolean |
| nodes.label.color | Label text color. | string |
| nodes.label.fontSize | Label text size. | number |
| nodes.label.fontWeight | Label font weight. | string \| number |
| nodes.label.formatter | Formats label text. | string \| function |
| nodes.x | X coordinate or category. | number |
| nodes.y | Y coordinate or category. | number |
| nodes.size | Per-record size. | number |
| links | Graph connections. Each link connects source and target node ids or names. Same effect as edges. | Array<object> |
| links.source | Source node id or name. | string \| number |
| links.target | Target node id or name. | string \| number |
| edges | Same effect as links. Graph connections. Each link connects source and target node ids or names. | Array<object> |
| edges.source | Source node id or name. | string \| number |
| edges.target | Target node id or name. | string \| number |
| symbolSize | Node size. When omitted, numeric value can be used to infer size. | number \| number[] \| function |
| center | Series center point inside the chart rectangle. | [number \| string, number \| string] |
| layout | Nested graph layout options. | Object |
| layoutOptions | Alias for nested graph layout options. | Object |
| layout.rows | Requested grid row count. Same effect as rows. | number |
| layout.cols | Requested grid column count. Same effect as cols. | number |
| layout.begin | Top-left origin of the grid. Same effect as begin. | [number \| string, number \| string] |
| layout.condense | Lets grid cells shrink to fit the node sizes. Same effect as condense. | boolean |
| layout.position | Pins a node to a row and column. Same effect as position. | function(node) => { row, col } |
| layout.sortBy | Sorts nodes before filling free cells. Same effect as sortBy. | string \| function; common values include 'data' and 'degree' |
| layout.nodeSize | Node size used to calculate cell size. Same effect as nodeSize. | number \| number[] \| function |
| layout.nodeSpacing | Extra node spacing used by the grid. Same effect as nodeSpacing. | number \| function |
| layout.preventOverlap | Increases cell size to avoid overlap. Same effect as preventOverlap. | boolean |
| layout.preventOverlapPadding | Extra gap for overlap prevention. Same effect as preventOverlapPadding. | number |
| rows | Same effect as layout.rows. Requested grid row count. | number |
| cols | Same effect as layout.cols. Requested grid column count. | number |
| begin | Same effect as layout.begin. Top-left origin of the grid. | [number \| string, number \| string] |
| condense | Same effect as layout.condense. Lets grid cells shrink to fit the node sizes. | boolean |
| position | Same effect as layout.position. Pins a node to a row and column. | function(node) => { row, col } |
| sortBy | Same effect as layout.sortBy. Sorts nodes before filling free cells. | string \| function; common values include 'data' and 'degree' |
| nodeSize | Same effect as layout.nodeSize. Node size used to calculate cell size. | number \| number[] \| function |
| nodeSpacing | Same effect as layout.nodeSpacing. Extra node spacing used by the grid. | number \| function |
| preventOverlap | Same effect as layout.preventOverlap. Increases cell size to avoid overlap. | boolean |
| preventOverlapPadding | Same effect as layout.preventOverlapPadding. Extra gap for overlap prevention. | number |
| itemStyle | Styles graph nodes. | Object |
| itemStyle.color | Primary color. | string |
| itemStyle.opacity | Opacity. | number |
| itemStyle.borderColor | Border color. | string |
| itemStyle.borderWidth | Border width. | number |
| itemStyle.shadowBlur | Shadow blur radius. | number |
| itemStyle.shadowColor | Shadow color. | string |
| edgeStyle | Styles graph edges. | Object |
| edgeStyle.color | Primary color. | string |
| edgeStyle.stroke | Stroke color. | string |
| edgeStyle.width | Width value. | number |
| edgeStyle.lineWidth | Line width. | number |
| edgeStyle.opacity | Opacity. | number |
| edgeStyle.type | Line or item type. | 'solid' \| 'dashed' \| 'dotted' \| number[] |
| label | Styles graph node labels. | Object |
| label.show | Shows labels when true. | boolean |
| label.position | Label position. | string |
| label.color | Label text color. | string |
| label.fontSize | Label text size. | number |
| label.fontWeight | Label font weight. | string \| number |
| label.formatter | Formats label text. | string \| function |
| label.offset | Distance between label and target element. | number |
| emphasis | Styles nodes and edges while hovered. | Object |
| emphasis.itemStyle | Nested item style option. | object |
| emphasis.itemStyle.color | Fill color. | string |
| emphasis.itemStyle.fill | Alias for fill color. | string |
| emphasis.itemStyle.opacity | Fill opacity. | number |
| emphasis.itemStyle.borderColor | Border color. | string |
| emphasis.itemStyle.borderWidth | Border width. | number |
| emphasis.itemStyle.borderRadius | Corner radius. | number |
| emphasis.itemStyle.shadowBlur | Shadow blur radius. | number |
| emphasis.itemStyle.shadowColor | Shadow color. | string |
| emphasis.itemStyle.lineWidth | Stroke width used by icon or shape styles. | number |
| emphasis.edgeStyle | Nested edgeStyle option. | object |
| emphasis.edgeStyle.color | Fill color. | string |
| emphasis.edgeStyle.fill | Alias for fill color. | string |
| emphasis.edgeStyle.opacity | Fill opacity. | number |
| emphasis.edgeStyle.borderColor | Border color. | string |
| emphasis.edgeStyle.borderWidth | Border width. | number |
| emphasis.edgeStyle.borderRadius | Corner radius. | number |
| emphasis.edgeStyle.shadowBlur | Shadow blur radius. | number |
| emphasis.edgeStyle.shadowColor | Shadow color. | string |
| emphasis.edgeStyle.lineWidth | Stroke width used by icon or shape styles. | number |
| emphasis.focus | Nested focus option. | string |
| emphasis.blurScope | Nested blurScope option. | string |
| enterAnimation | Animates nodes into place. | boolean \| object |
| enterAnimation.show | Shows the animation when true. | boolean |
| enterAnimation.enabled | Enables the animation when true. | boolean |
| enterAnimation.duration | Animation duration. | number \| function |
| enterAnimation.delay | Delay before the animation starts. | number \| function |
| enterAnimation.stagger | Delay added between items. | number \| function |
| enterAnimation.easing | Animation easing name. | string |
| edgeAnimation | Animates edge drawing. | boolean \| object |
| edgeAnimation.show | Shows the animation when true. | boolean |
| edgeAnimation.enabled | Enables the animation when true. | boolean |
| edgeAnimation.duration | Animation duration. | number \| function |
| edgeAnimation.delay | Delay before the animation starts. | number \| function |
| edgeAnimation.stagger | Delay added between items. | number \| function |
| edgeAnimation.easing | Animation easing name. | string |
| fisheye | Configures the built-in pointer magnifier for this graph series. | false \| object |
| fisheye.show | Shows and enables the magnifier when true. | boolean |
| fisheye.radius | Lens radius around the pointer. | number \| string (pixel or percent) |
| fisheye.scale | Magnification factor at the lens center. | number |
| fisheye.labelScale | Label magnification factor near the lens center. | number |
| fisheye.stroke | Lens outline color. | string |
| fisheye.strokeWidth | Lens outline width. | number |
| fisheye.opacity | Lens outline opacity. | number |
| fisheye.preview | Runs an initial preview pulse when available. | boolean |
| layoutAnimation | ECharts layout animation flag for the registered series. | boolean |
