install.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. import GeoModel from '../../coord/geo/GeoModel.js';
  41. import geoCreator from '../../coord/geo/geoCreator.js';
  42. import { COMPONENT_MAIN_TYPE_SERIES } from '../../util/types.js';
  43. import { each } from 'zrender/lib/core/util.js';
  44. import { mapSeriesNeedsDrawMap } from '../../chart/map/MapSeries.js';
  45. import GeoView from './GeoView.js';
  46. import geoSourceManager from '../../coord/geo/geoSourceManager.js';
  47. import { makeQueryConditionKindA } from '../../util/model.js';
  48. import { ownRoamModelCoordSysUpdateInAction, ownRoamViewUpdateDirectlyInAction } from '../../coord/View.js';
  49. function registerMap(mapName, geoJson, specialAreas) {
  50. geoSourceManager.registerMap(mapName, geoJson, specialAreas);
  51. }
  52. export function install(registers) {
  53. registers.registerCoordinateSystem('geo', geoCreator);
  54. registers.registerComponentModel(GeoModel);
  55. registers.registerComponentView(GeoView);
  56. registers.registerImpl('registerMap', registerMap);
  57. registers.registerImpl('getMap', function (mapName) {
  58. return geoSourceManager.getMapForUser(mapName);
  59. });
  60. function makeAction(method, actionInfo) {
  61. actionInfo.update = 'geo:updateSelectStatus';
  62. registers.registerAction(actionInfo, function (payload, ecModel) {
  63. var selected = {};
  64. var allSelected = [];
  65. ecModel.eachComponent({
  66. mainType: 'geo',
  67. query: payload
  68. }, function (geoModel) {
  69. geoModel[method](payload.name);
  70. var geo = geoModel.coordinateSystem;
  71. each(geo.regions, function (region) {
  72. selected[region.name] = geoModel.isSelected(region.name) || false;
  73. });
  74. // Notice: there might be duplicated name in different regions.
  75. var names = [];
  76. each(selected, function (v, name) {
  77. selected[name] && names.push(name);
  78. });
  79. allSelected.push({
  80. geoIndex: geoModel.componentIndex,
  81. // Use singular, the same naming convention as the event `selectchanged`.
  82. name: names
  83. });
  84. });
  85. return {
  86. selected: selected,
  87. allSelected: allSelected,
  88. name: payload.name
  89. };
  90. });
  91. }
  92. makeAction('toggleSelected', {
  93. type: 'geoToggleSelect',
  94. event: 'geoselectchanged'
  95. });
  96. makeAction('select', {
  97. type: 'geoSelect',
  98. event: 'geoselected'
  99. });
  100. makeAction('unSelect', {
  101. type: 'geoUnSelect',
  102. event: 'geounselected'
  103. });
  104. /**
  105. * @payload
  106. * @property {string} [componentType=series]
  107. * @property {number} [dx]
  108. * @property {number} [dy]
  109. * @property {number} [zoom]
  110. * @property {number} [originX]
  111. * @property {number} [originY]
  112. */
  113. registers.registerAction({
  114. type: 'geoRoam',
  115. event: 'geoRoam',
  116. update: 'updateTransform'
  117. }, function (payload, ecModel, api) {
  118. // `payload.componentType` is supported only for backward compatibility.
  119. var mainType = payload.componentType || (payload.geoId != null || payload.geoName != null || payload.geoIndex != null ? 'geo' : COMPONENT_MAIN_TYPE_SERIES);
  120. var isSeries = mainType === COMPONENT_MAIN_TYPE_SERIES;
  121. if (mainType !== 'geo' && !isSeries) {
  122. return;
  123. }
  124. var subType = isSeries ? 'map' : null;
  125. ecModel.eachComponent(makeQueryConditionKindA(payload, mainType, subType), function (componentOrSeries) {
  126. if (isSeries
  127. // Only when `needsDrawMap: true`, the `MapSeries` host geo coord sys and call `MapDraw`.
  128. && !mapSeriesNeedsDrawMap(componentOrSeries)) {
  129. return;
  130. }
  131. // Since 'updateTransform' is used, geo model and view update firstly here, and then series
  132. // and components laid out on this VIEW_COORD_SYS update in `View['updateTransform']`.
  133. ownRoamModelCoordSysUpdateInAction(payload, componentOrSeries, isSeries ? componentOrSeries.seriesGroup.r : null);
  134. ownRoamViewUpdateDirectlyInAction(payload, componentOrSeries, ecModel, api);
  135. });
  136. });
  137. }