DataZoomView.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. var ComponentView = require("../../view/Component");
  2. var _default = ComponentView.extend({
  3. type: 'dataZoom',
  4. render: function (dataZoomModel, ecModel, api, payload) {
  5. this.dataZoomModel = dataZoomModel;
  6. this.ecModel = ecModel;
  7. this.api = api;
  8. },
  9. /**
  10. * Find the first target coordinate system.
  11. *
  12. * @protected
  13. * @return {Object} {
  14. * grid: [
  15. * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1},
  16. * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0},
  17. * ...
  18. * ], // cartesians must not be null/undefined.
  19. * polar: [
  20. * {model: coord0, axisModels: [axis4], coordIndex: 0},
  21. * ...
  22. * ], // polars must not be null/undefined.
  23. * singleAxis: [
  24. * {model: coord0, axisModels: [], coordIndex: 0}
  25. * ]
  26. */
  27. getTargetCoordInfo: function () {
  28. var dataZoomModel = this.dataZoomModel;
  29. var ecModel = this.ecModel;
  30. var coordSysLists = {};
  31. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  32. var axisModel = ecModel.getComponent(dimNames.axis, axisIndex);
  33. if (axisModel) {
  34. var coordModel = axisModel.getCoordSysModel();
  35. coordModel && save(coordModel, axisModel, coordSysLists[coordModel.mainType] || (coordSysLists[coordModel.mainType] = []), coordModel.componentIndex);
  36. }
  37. }, this);
  38. function save(coordModel, axisModel, store, coordIndex) {
  39. var item;
  40. for (var i = 0; i < store.length; i++) {
  41. if (store[i].model === coordModel) {
  42. item = store[i];
  43. break;
  44. }
  45. }
  46. if (!item) {
  47. store.push(item = {
  48. model: coordModel,
  49. axisModels: [],
  50. coordIndex: coordIndex
  51. });
  52. }
  53. item.axisModels.push(axisModel);
  54. }
  55. return coordSysLists;
  56. }
  57. });
  58. module.exports = _default;