sunburstAction.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 { extend } from 'zrender/lib/core/util.js';
  41. import { deprecateReplaceLog } from '../../util/log.js';
  42. import { retrieveTargetInfo, aboveViewRoot } from '../helper/treeHelper.js';
  43. export var ROOT_TO_NODE_ACTION = 'sunburstRootToNode';
  44. var HIGHLIGHT_ACTION = 'sunburstHighlight';
  45. var UNHIGHLIGHT_ACTION = 'sunburstUnhighlight';
  46. export function installSunburstAction(registers) {
  47. registers.registerAction({
  48. type: ROOT_TO_NODE_ACTION,
  49. update: 'updateView'
  50. }, function (payload, ecModel) {
  51. ecModel.eachComponent({
  52. mainType: 'series',
  53. subType: 'sunburst',
  54. query: payload
  55. }, handleRootToNode);
  56. function handleRootToNode(model, index) {
  57. var targetInfo = retrieveTargetInfo(payload, [ROOT_TO_NODE_ACTION], model);
  58. if (targetInfo) {
  59. var originViewRoot = model.getViewRoot();
  60. if (originViewRoot) {
  61. payload.direction = aboveViewRoot(originViewRoot, targetInfo.node) ? 'rollUp' : 'drillDown';
  62. }
  63. model.resetViewRoot(targetInfo.node);
  64. }
  65. }
  66. });
  67. registers.registerAction({
  68. type: HIGHLIGHT_ACTION,
  69. update: 'none'
  70. }, function (payload, ecModel, api) {
  71. // Clone
  72. payload = extend({}, payload);
  73. ecModel.eachComponent({
  74. mainType: 'series',
  75. subType: 'sunburst',
  76. query: payload
  77. }, handleHighlight);
  78. function handleHighlight(model) {
  79. var targetInfo = retrieveTargetInfo(payload, [HIGHLIGHT_ACTION], model);
  80. if (targetInfo) {
  81. payload.dataIndex = targetInfo.node.dataIndex;
  82. }
  83. }
  84. if (process.env.NODE_ENV !== 'production') {
  85. deprecateReplaceLog('highlight', 'sunburstHighlight');
  86. } // Fast forward action
  87. api.dispatchAction(extend(payload, {
  88. type: 'highlight'
  89. }));
  90. });
  91. registers.registerAction({
  92. type: UNHIGHLIGHT_ACTION,
  93. update: 'updateView'
  94. }, function (payload, ecModel, api) {
  95. payload = extend({}, payload);
  96. if (process.env.NODE_ENV !== 'production') {
  97. deprecateReplaceLog('downplay', 'sunburstUnhighlight');
  98. }
  99. api.dispatchAction(extend(payload, {
  100. type: 'downplay'
  101. }));
  102. });
  103. }