blob: d20b9c70f86926f9b9331e96a479e2cba6a4c8d5 [file] [log] [blame]
import * as echarts from '../echarts';
import * as zrUtil from 'zrender/src/core/util';
import * as graphic from '../util/graphic';
import '../coord/cartesian/Grid';
import './axis'; // Grid view
echarts.extendComponentView({
type: 'grid',
render: function (gridModel, ecModel) {
this.group.removeAll();
if (gridModel.get('show')) {
this.group.add(new graphic.Rect({
shape: gridModel.coordinateSystem.getRect(),
style: zrUtil.defaults({
fill: gridModel.get('backgroundColor')
}, gridModel.getItemStyle()),
silent: true,
z2: -1
}));
}
}
});
echarts.registerPreprocessor(function (option) {
// Only create grid when need
if (option.xAxis && option.yAxis && !option.grid) {
option.grid = {};
}
});