gridSimple.js 788 B

12345678910111213141516171819202122232425262728293031323334
  1. var echarts = require("../echarts");
  2. var zrUtil = require("zrender/lib/core/util");
  3. var graphic = require("../util/graphic");
  4. require("../coord/cartesian/Grid");
  5. require("./axis");
  6. // Grid view
  7. echarts.extendComponentView({
  8. type: 'grid',
  9. render: function (gridModel, ecModel) {
  10. this.group.removeAll();
  11. if (gridModel.get('show')) {
  12. this.group.add(new graphic.Rect({
  13. shape: gridModel.coordinateSystem.getRect(),
  14. style: zrUtil.defaults({
  15. fill: gridModel.get('backgroundColor')
  16. }, gridModel.getItemStyle()),
  17. silent: true,
  18. z2: -1
  19. }));
  20. }
  21. }
  22. });
  23. echarts.registerPreprocessor(function (option) {
  24. // Only create grid when need
  25. if (option.xAxis && option.yAxis && !option.grid) {
  26. option.grid = {};
  27. }
  28. });