gridSimple.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. var echarts = require("../echarts");
  20. var zrUtil = require("zrender/lib/core/util");
  21. var graphic = require("../util/graphic");
  22. require("../coord/cartesian/Grid");
  23. require("./axis");
  24. /*
  25. * Licensed to the Apache Software Foundation (ASF) under one
  26. * or more contributor license agreements. See the NOTICE file
  27. * distributed with this work for additional information
  28. * regarding copyright ownership. The ASF licenses this file
  29. * to you under the Apache License, Version 2.0 (the
  30. * "License"); you may not use this file except in compliance
  31. * with the License. You may obtain a copy of the License at
  32. *
  33. * http://www.apache.org/licenses/LICENSE-2.0
  34. *
  35. * Unless required by applicable law or agreed to in writing,
  36. * software distributed under the License is distributed on an
  37. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38. * KIND, either express or implied. See the License for the
  39. * specific language governing permissions and limitations
  40. * under the License.
  41. */
  42. // Grid view
  43. echarts.extendComponentView({
  44. type: 'grid',
  45. render: function (gridModel, ecModel) {
  46. this.group.removeAll();
  47. if (gridModel.get('show')) {
  48. this.group.add(new graphic.Rect({
  49. shape: gridModel.coordinateSystem.getRect(),
  50. style: zrUtil.defaults({
  51. fill: gridModel.get('backgroundColor')
  52. }, gridModel.getItemStyle()),
  53. silent: true,
  54. z2: -1
  55. }));
  56. }
  57. }
  58. });
  59. echarts.registerPreprocessor(function (option) {
  60. // Only create grid when need
  61. if (option.xAxis && option.yAxis && !option.grid) {
  62. option.grid = {};
  63. }
  64. });