AxisModel.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 = /** @class */function (_super) {
  47. __extends(ParallelAxisModel, _super);
  48. function ParallelAxisModel() {
  49. var _this = _super !== null && _super.apply(this, arguments) || this;
  50. _this.type = ParallelAxisModel.type;
  51. /**
  52. * @readOnly
  53. */
  54. _this.activeIntervals = [];
  55. return _this;
  56. }
  57. ParallelAxisModel.prototype.getAreaSelectStyle = function () {
  58. return makeStyleMapper([['fill', 'color'], ['lineWidth', 'borderWidth'], ['stroke', 'borderColor'], ['width', 'width'], ['opacity', 'opacity']
  59. // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  60. // So do not transfer decal directly.
  61. ])(this.getModel('areaSelectStyle'));
  62. };
  63. /**
  64. * The code of this feature is put on AxisModel but not ParallelAxis,
  65. * because axisModel can be alive after echarts updating but instance of
  66. * ParallelAxis having been disposed. this._activeInterval should be kept
  67. * when action dispatched (i.e. legend click).
  68. *
  69. * @param intervals `interval.length === 0` means set all active.
  70. */
  71. ParallelAxisModel.prototype.setActiveIntervals = function (intervals) {
  72. var activeIntervals = this.activeIntervals = zrUtil.clone(intervals);
  73. // 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. }
  92. // Simple optimization
  93. if (activeIntervals.length === 1) {
  94. var interval = activeIntervals[0];
  95. if (interval[0] <= value && value <= interval[1]) {
  96. return 'active';
  97. }
  98. } else {
  99. for (var i = 0, len = activeIntervals.length; i < len; i++) {
  100. if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) {
  101. return 'active';
  102. }
  103. }
  104. }
  105. return 'inactive';
  106. };
  107. return ParallelAxisModel;
  108. }(ComponentModel);
  109. zrUtil.mixin(ParallelAxisModel, AxisModelCommonMixin);
  110. export default ParallelAxisModel;