提交 c2f73f88 编写于 作者: L lang

Fix some bug when retrieving grid with id

上级 f7e97902
......@@ -38,7 +38,7 @@ define(function (require) {
return;
}
var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex'));
var gridModel = axisModel.findGridModel();
var layout = layoutAxis(gridModel, axisModel);
......
......@@ -58,18 +58,6 @@ define(function (require) {
if (coordModel != null) {
save(coordModel, axisModel, coordSysName === 'grid' ? cartesians : polars, coordModel.componentIndex);
}
// var gridIndex = axisModel.get('gridIndex');
// var polarIndex = axisModel.get('polarIndex');
// if (gridIndex != null) {
// var coordModel = ecModel.getComponent('grid', gridIndex);
// save(coordModel, axisModel, cartesians, gridIndex);
// }
// else if (polarIndex != null) {
// var coordModel = ecModel.getComponent('polar', polarIndex);
// save(coordModel, axisModel, polars, polarIndex);
// }
}
}, this);
......
......@@ -77,6 +77,17 @@ define(function(require) {
? false : !option.scale;
},
/**
* @return {module:echarts/model/Model}
*/
findGridModel: function () {
return this.ecModel.queryComponents({
mainType: 'grid',
index: this.get('gridIndex'),
id: this.get('gridId')
})[0];
},
/**
* @private
*/
......
......@@ -25,7 +25,7 @@ define(function(require, factory) {
* @inner
*/
function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) {
return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel;
return axisModel.findGridModel() === gridModel;
}
function getLabelUnionRect(axis) {
......@@ -450,11 +450,7 @@ define(function(require, factory) {
var xAxisModel = axesModels[0];
var yAxisModel = axesModels[1];
var gridModel = ecModel.queryComponents({
mainType: 'grid',
index: xAxisModel.get('gridIndex'),
id: xAxisModel.get('gridId')
})[0];
var gridModel = xAxisModel.findGridModel();
if (__DEV__) {
if (!gridModel) {
......@@ -466,7 +462,7 @@ define(function(require, factory) {
) + '" not found'
);
}
if (yAxisModel.get('gridIndex') !== yAxisModel.get('gridIndex')) {
if (xAxisModel.findGridModel() !== yAxisModel.findGridModel()) {
throw new Error('xAxis and yAxis must use the same grid');
}
}
......
......@@ -55,7 +55,8 @@
}],
xAxis: [{
id: id,
gridIndex: idx,
gridId: id,
// gridIndex: idx,
axisLabel: {
show: j === dimSize - 1
},
......@@ -69,7 +70,8 @@
}],
yAxis: [{
id: id,
gridIndex: idx,
gridId: id,
// gridIndex: idx,
axisLabel: {
show: i === 1
},
......@@ -87,8 +89,10 @@
hoverAnimation: false,
name: nameList[dataIdx],
type: 'scatter',
xAxisIndex: idx,
yAxisIndex: idx,
xAxisId: id,
yAxisId: id,
// xAxisIndex: idx,
// yAxisIndex: idx,
data: data.map(function (item) {
return [item[i], item[j]];
}),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册