AxisModel.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 { __extends } from "tslib";
  41. import * as zrUtil from 'zrender/lib/core/util.js';
  42. import ComponentModel from '../../model/Component.js';
  43. import makeStyleMapper from '../../model/mixin/makeStyleMapper.js';
  44. import * as numberUtil from '../../util/number.js';
  45. import { AxisModelCommonMixin } from '../axisModelCommonMixin.js';
  46. var ParallelAxisModel =
  47. /** @class */
  48. function (_super) {
  49. __extends(ParallelAxisModel, _super);
  50. function ParallelAxisModel() {
  51. var _this = _super !== null && _super.apply(this, arguments) || this;
  52. _this.type = ParallelAxisModel.type;
  53. /**
  54. * @readOnly
  55. */
  56. _this.activeIntervals = [];
  57. return _this;
  58. }
  59. ParallelAxisModel.prototype.getAreaSelectStyle = function () {
  60. return makeStyleMapper([['fill', 'color'], ['lineWidth', 'borderWidth'], ['stroke', 'borderColor'], ['width', 'width'], ['opacity', 'opacity'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  61. // So do not transfer decal directly.
  62. ])(this.getModel('areaSelectStyle'));
  63. };
  64. /**
  65. * The code of this feature is put on AxisModel but not ParallelAxis,
  66. * because axisModel can be alive after echarts updating but instance of
  67. * ParallelAxis having been disposed. this._activeInterval should be kept
  68. * when action dispatched (i.e. legend click).
  69. *
  70. * @param intervals `interval.length === 0` means set all active.
  71. */
  72. ParallelAxisModel.prototype.setActiveIntervals = function (intervals) {
  73. var activeIntervals = this.activeIntervals = zrUtil.clone(intervals); // Normalize
  74. if (activeIntervals) {
  75. for (var i = activeIntervals.length - 1; i >= 0; i--) {
  76. numberUtil.asc(activeIntervals[i]);
  77. }
  78. }
  79. };
  80. /**
  81. * @param value When only attempting detect whether 'no activeIntervals set',
  82. * `value` is not needed to be input.
  83. */
  84. ParallelAxisModel.prototype.getActiveState = function (value) {
  85. var activeIntervals = this.activeIntervals;
  86. if (!activeIntervals.length) {
  87. return 'normal';
  88. }
  89. if (value == null || isNaN(+value)) {
  90. return 'inactive';
  91. } // Simple optimization
  92. if (activeIntervals.length === 1) {
  93. var interval = activeIntervals[0];
  94. if (interval[0] <= value && value <= interval[1]) {
  95. return 'active';
  96. }
  97. } else {
  98. for (var i = 0, len = activeIntervals.length; i < len; i++) {
  99. if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) {
  100. return 'active';
  101. }
  102. }
  103. }
  104. return 'inactive';
  105. };
  106. return ParallelAxisModel;
  107. }(ComponentModel);
  108. zrUtil.mixin(ParallelAxisModel, AxisModelCommonMixin);
  109. export default ParallelAxisModel;