axisAction.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 { parseFinder } from '../../util/model.js';
  41. import { defaults, each } from 'zrender/lib/core/util.js';
  42. export var AXIS_BREAK_EXPAND_ACTION_TYPE = 'expandAxisBreak';
  43. export var AXIS_BREAK_COLLAPSE_ACTION_TYPE = 'collapseAxisBreak';
  44. export var AXIS_BREAK_TOGGLE_ACTION_TYPE = 'toggleAxisBreak';
  45. var AXIS_BREAK_CHANGED_EVENT_TYPE = 'axisbreakchanged';
  46. var expandAxisBreakActionInfo = {
  47. type: AXIS_BREAK_EXPAND_ACTION_TYPE,
  48. event: AXIS_BREAK_CHANGED_EVENT_TYPE,
  49. update: 'update',
  50. refineEvent: refineAxisBreakChangeEvent
  51. };
  52. var collapseAxisBreakActionInfo = {
  53. type: AXIS_BREAK_COLLAPSE_ACTION_TYPE,
  54. event: AXIS_BREAK_CHANGED_EVENT_TYPE,
  55. update: 'update',
  56. refineEvent: refineAxisBreakChangeEvent
  57. };
  58. var toggleAxisBreakActionInfo = {
  59. type: AXIS_BREAK_TOGGLE_ACTION_TYPE,
  60. event: AXIS_BREAK_CHANGED_EVENT_TYPE,
  61. update: 'update',
  62. refineEvent: refineAxisBreakChangeEvent
  63. };
  64. function refineAxisBreakChangeEvent(actionResultBatch, payload, ecModel, api) {
  65. var breaks = [];
  66. each(actionResultBatch, function (actionResult) {
  67. breaks = breaks.concat(actionResult.eventBreaks);
  68. });
  69. return {
  70. eventContent: {
  71. breaks: breaks
  72. }
  73. };
  74. }
  75. export function registerAction(registers) {
  76. registers.registerAction(expandAxisBreakActionInfo, actionHandler);
  77. registers.registerAction(collapseAxisBreakActionInfo, actionHandler);
  78. registers.registerAction(toggleAxisBreakActionInfo, actionHandler);
  79. function actionHandler(payload, ecModel) {
  80. var eventBreaks = [];
  81. var finderResult = parseFinder(ecModel, payload);
  82. function dealUpdate(modelProp, indexProp) {
  83. each(finderResult[modelProp], function (axisModel) {
  84. var result = axisModel.updateAxisBreaks(payload);
  85. each(result.breaks, function (item) {
  86. var _a;
  87. eventBreaks.push(defaults((_a = {}, _a[indexProp] = axisModel.componentIndex, _a), item));
  88. });
  89. });
  90. }
  91. dealUpdate('xAxisModels', 'xAxisIndex');
  92. dealUpdate('yAxisModels', 'yAxisIndex');
  93. dealUpdate('singleAxisModels', 'singleAxisIndex');
  94. return {
  95. eventBreaks: eventBreaks
  96. };
  97. }
  98. }