{"record":{"id":"175448db556f178c","repo":"apache/echarts","slug":"xaxis-and-yaxis-must-use-the-same-grid","errorCode":null,"errorMessage":"xAxis and yAxis must use the same grid","messagePattern":"xAxis and yAxis must use the same grid","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coord/cartesian/Grid.ts","lineNumber":585,"sourceCode":"                const xAxisModel = axesModelMap.xAxisModel;\n                const yAxisModel = axesModelMap.yAxisModel;\n                xAxis = xAxisModel.axis;\n                yAxis = yAxisModel.axis;\n\n                const gridModel = xAxisModel.getCoordSysModel();\n\n                if (__DEV__) {\n                    if (!gridModel) {\n                        throw new Error(\n                            'Grid \"' + retrieve3(\n                                xAxisModel.get('gridIndex'),\n                                xAxisModel.get('gridId'),\n                                0\n                            ) + '\" not found'\n                        );\n                    }\n                    if (xAxisModel.getCoordSysModel() !== yAxisModel.getCoordSysModel()) {\n                        throw new Error('xAxis and yAxis must use the same grid');\n                    }\n                }\n\n                const grid = gridModel.coordinateSystem as Grid;\n\n                return grid.getCartesian(\n                    xAxisModel.componentIndex, yAxisModel.componentIndex\n                );\n            }\n            if (xAxis && yAxis) {\n                associateSeriesWithAxis(xAxis, seriesModel, COORD_SYS_TYPE_CARTESIAN_2D);\n                associateSeriesWithAxis(yAxis, seriesModel, COORD_SYS_TYPE_CARTESIAN_2D);\n            }\n\n        }, this);\n\n        return grids;\n    }","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/apache/echarts/blob/30076aedcd7b7f65d8dd8e8d9ece46ce778133a3/src/coord/cartesian/Grid.ts#L567-L603","documentation":"DEV-only guard in Grid.create: the xAxisModel and yAxisModel resolved for a series must belong to the same gridModel. If they reference different grids, no single cartesian system can be formed and it throws. Stripped in production.","triggerScenarios":"xAxis gridIndex=0 and yAxis gridIndex=1 (different grids) for a series; explicit gridId mismatch between the two axes; series xAxisIndex/yAxisIndex pointing at axes on different grids.","commonSituations":"Multiple grids configured; series bound to axes from different grids; axis config drift across versions.","solutions":["Make xAxis and yAxis reference the same grid (same gridIndex/gridId, or omit both for the default grid)","Drop explicit gridIndex/gridId when only a single grid is used","Verify each series' xAxisIndex and yAxisIndex land on the same grid"],"exampleFix":"// before\nxAxis: [{ gridIndex: 0 }],\nyAxis: [{ gridIndex: 1 }],\nseries: [{ type: 'line', xAxisIndex: 0, yAxisIndex: 0 }]\n\n// after\nxAxis: [{}],\nyAxis: [{}],\nseries: [{ type: 'line' }]","handlingStrategy":"validation","validationCode":"const xAxes = Array.isArray(option.xAxis) ? option.xAxis : (option.xAxis ? [option.xAxis] : []);\nconst yAxes = Array.isArray(option.yAxis) ? option.yAxis : (option.yAxis ? [option.yAxis] : []);\n(option.series || []).forEach((s: any) => {\n  const xi = s.xAxisIndex ?? 0;\n  const yi = s.yAxisIndex ?? 0;\n  const xg = xAxes[xi] && (xAxes[xi].gridIndex ?? 0);\n  const yg = yAxes[yi] && (yAxes[yi].gridIndex ?? 0);\n  if (xg !== yg) console.error('[grid] series ' + (s.name || '') + ' xAxis/yAxis on different grids');\n});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pair each series' xAxis and yAxis from the same grid","Avoid mixing gridIndex across paired axes","Drop explicit gridIndex when only a single grid is used"],"tags":["grid","axis","configuration","dev-only"],"backgroundTag":null,"analyzedSha":"30076aedcd7b7f65d8dd8e8d9ece46ce778133a3","analyzedAt":"2026-08-12T12:42:28.134Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}