DataZoomView.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 ComponentView = require("../../view/Component");
  20. /*
  21. * Licensed to the Apache Software Foundation (ASF) under one
  22. * or more contributor license agreements. See the NOTICE file
  23. * distributed with this work for additional information
  24. * regarding copyright ownership. The ASF licenses this file
  25. * to you under the Apache License, Version 2.0 (the
  26. * "License"); you may not use this file except in compliance
  27. * with the License. You may obtain a copy of the License at
  28. *
  29. * http://www.apache.org/licenses/LICENSE-2.0
  30. *
  31. * Unless required by applicable law or agreed to in writing,
  32. * software distributed under the License is distributed on an
  33. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  34. * KIND, either express or implied. See the License for the
  35. * specific language governing permissions and limitations
  36. * under the License.
  37. */
  38. var _default = ComponentView.extend({
  39. type: 'dataZoom',
  40. render: function (dataZoomModel, ecModel, api, payload) {
  41. this.dataZoomModel = dataZoomModel;
  42. this.ecModel = ecModel;
  43. this.api = api;
  44. },
  45. /**
  46. * Find the first target coordinate system.
  47. *
  48. * @protected
  49. * @return {Object} {
  50. * grid: [
  51. * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1},
  52. * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0},
  53. * ...
  54. * ], // cartesians must not be null/undefined.
  55. * polar: [
  56. * {model: coord0, axisModels: [axis4], coordIndex: 0},
  57. * ...
  58. * ], // polars must not be null/undefined.
  59. * singleAxis: [
  60. * {model: coord0, axisModels: [], coordIndex: 0}
  61. * ]
  62. */
  63. getTargetCoordInfo: function () {
  64. var dataZoomModel = this.dataZoomModel;
  65. var ecModel = this.ecModel;
  66. var coordSysLists = {};
  67. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  68. var axisModel = ecModel.getComponent(dimNames.axis, axisIndex);
  69. if (axisModel) {
  70. var coordModel = axisModel.getCoordSysModel();
  71. coordModel && save(coordModel, axisModel, coordSysLists[coordModel.mainType] || (coordSysLists[coordModel.mainType] = []), coordModel.componentIndex);
  72. }
  73. }, this);
  74. function save(coordModel, axisModel, store, coordIndex) {
  75. var item;
  76. for (var i = 0; i < store.length; i++) {
  77. if (store[i].model === coordModel) {
  78. item = store[i];
  79. break;
  80. }
  81. }
  82. if (!item) {
  83. store.push(item = {
  84. model: coordModel,
  85. axisModels: [],
  86. coordIndex: coordIndex
  87. });
  88. }
  89. item.axisModels.push(axisModel);
  90. }
  91. return coordSysLists;
  92. }
  93. });
  94. module.exports = _default;