apache/echarts · error
Grid "{}" not found
Error message
Grid "{}" not found What it means
DEV-only guard in Grid.create's coordSysProvider: after resolving xAxisModel/yAxisModel for a cartesian2d series, it looks up the grid model they belong to via getCoordSysModel. If none is found (no grid component registered, or gridIndex/gridId mismatch), it throws with the resolved index/id. Stripped in production.
Source
Thrown at src/coord/cartesian/Grid.ts:576
injectCoordSysByOption({
targetModel: seriesModel,
coordSysType: COORD_SYS_TYPE_CARTESIAN_2D,
coordSysProvider: coordSysProvider
});
function coordSysProvider() {
const axesModelMap = findAxisModels(seriesModel);
const xAxisModel = axesModelMap.xAxisModel;
const yAxisModel = axesModelMap.yAxisModel;
xAxis = xAxisModel.axis;
yAxis = yAxisModel.axis;
const gridModel = xAxisModel.getCoordSysModel();
if (__DEV__) {
if (!gridModel) {
throw new Error(
'Grid "' + retrieve3(
xAxisModel.get('gridIndex'),
xAxisModel.get('gridId'),
0
) + '" not found'
);
}
if (xAxisModel.getCoordSysModel() !== yAxisModel.getCoordSysModel()) {
throw new Error('xAxis and yAxis must use the same grid');
}
}
const grid = gridModel.coordinateSystem as Grid;
return grid.getCartesian(
xAxisModel.componentIndex, yAxisModel.componentIndex
);
}View on GitHub (pinned to 30076aedcd)
Solutions
- Register GridComponent on modular builds (echarts.use([GridComponent]))
- Ensure a grid component exists, or rely on the implicit default single grid
- Match gridIndex/gridId to an existing grid, or drop them
Example fix
// before (modular, grid not registered)
import * as echarts from 'echarts/core';
import { BarChart } from 'echarts/charts';
echarts.use([BarChart]);
// after
import { GridComponent } from 'echarts/components';
echarts.use([BarChart, GridComponent]); Defensive patterns
Strategy: validation
Validate before calling
// on modular builds, ensure GridComponent is registered:
// echarts.use([GridComponent]);
// before setOption, verify gridIndex/gridId resolve:
const grids = Array.isArray(option.grid) ? option.grid : (option.grid ? [option.grid] : []);
(option.series || []).forEach((s: any) => {
if (s.gridIndex != null && s.gridIndex >= grids.length) {
console.error('[grid] series.gridIndex out of range: ' + s.gridIndex);
}
}); Prevention
- Register GridComponent on modular builds
- Validate gridIndex/gridId reference an existing grid before setOption
- Rely on the implicit default single grid when只有一个 grid is needed
When it happens
Trigger: Modular build without GridComponent registered; series xAxis referencing gridIndex/gridId that points to no grid; grid component omitted from the option.
Common situations: Minimal 'echarts/core' build missing GridComponent; gridIndex out of range; gridId typo; relying on default grid that was never created.
Related errors
- Unknown coordinate system {}
- Line not support coordinateSystem besides cartesian and pola
- xAxis and yAxis must use the same grid
- {} "{}" not found
- key must not be "{}"
AI-assisted analysis of apache/echarts@30076aedcd (2026-08-12).
Data as JSON: /api/errors/848377d7c713a2cb.
Report an issue: GitHub.