graphAction.js 2.4 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 _roamHelper = require("../../action/roamHelper");
  21. var updateCenterAndZoom = _roamHelper.updateCenterAndZoom;
  22. require("../helper/focusNodeAdjacencyAction");
  23. /*
  24. * Licensed to the Apache Software Foundation (ASF) under one
  25. * or more contributor license agreements. See the NOTICE file
  26. * distributed with this work for additional information
  27. * regarding copyright ownership. The ASF licenses this file
  28. * to you under the Apache License, Version 2.0 (the
  29. * "License"); you may not use this file except in compliance
  30. * with the License. You may obtain a copy of the License at
  31. *
  32. * http://www.apache.org/licenses/LICENSE-2.0
  33. *
  34. * Unless required by applicable law or agreed to in writing,
  35. * software distributed under the License is distributed on an
  36. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  37. * KIND, either express or implied. See the License for the
  38. * specific language governing permissions and limitations
  39. * under the License.
  40. */
  41. var actionInfo = {
  42. type: 'graphRoam',
  43. event: 'graphRoam',
  44. update: 'none'
  45. };
  46. /**
  47. * @payload
  48. * @property {string} name Series name
  49. * @property {number} [dx]
  50. * @property {number} [dy]
  51. * @property {number} [zoom]
  52. * @property {number} [originX]
  53. * @property {number} [originY]
  54. */
  55. echarts.registerAction(actionInfo, function (payload, ecModel) {
  56. ecModel.eachComponent({
  57. mainType: 'series',
  58. query: payload
  59. }, function (seriesModel) {
  60. var coordSys = seriesModel.coordinateSystem;
  61. var res = updateCenterAndZoom(coordSys, payload);
  62. seriesModel.setCenter && seriesModel.setCenter(res.center);
  63. seriesModel.setZoom && seriesModel.setZoom(res.zoom);
  64. });
  65. });