ScrollableLegendModel.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 LegendModel from './LegendModel.js';
  42. import { mergeLayoutParam, getLayoutParams } from '../../util/layout.js';
  43. import { inheritDefaultOption } from '../../util/component.js';
  44. var ScrollableLegendModel = /** @class */function (_super) {
  45. __extends(ScrollableLegendModel, _super);
  46. function ScrollableLegendModel() {
  47. var _this = _super !== null && _super.apply(this, arguments) || this;
  48. _this.type = ScrollableLegendModel.type;
  49. return _this;
  50. }
  51. /**
  52. * @param {number} scrollDataIndex
  53. */
  54. ScrollableLegendModel.prototype.setScrollDataIndex = function (scrollDataIndex) {
  55. this.option.scrollDataIndex = scrollDataIndex;
  56. };
  57. ScrollableLegendModel.prototype.init = function (option, parentModel, ecModel) {
  58. var inputPositionParams = getLayoutParams(option);
  59. _super.prototype.init.call(this, option, parentModel, ecModel);
  60. mergeAndNormalizeLayoutParams(this, option, inputPositionParams);
  61. };
  62. /**
  63. * @override
  64. */
  65. ScrollableLegendModel.prototype.mergeOption = function (option, ecModel) {
  66. _super.prototype.mergeOption.call(this, option, ecModel);
  67. mergeAndNormalizeLayoutParams(this, this.option, option);
  68. };
  69. ScrollableLegendModel.type = 'legend.scroll';
  70. ScrollableLegendModel.defaultOption = inheritDefaultOption(LegendModel.defaultOption, {
  71. scrollDataIndex: 0,
  72. pageButtonItemGap: 5,
  73. pageButtonGap: null,
  74. pageButtonPosition: 'end',
  75. pageFormatter: '{current}/{total}',
  76. pageIcons: {
  77. horizontal: ['M0,0L12,-10L12,10z', 'M0,0L-12,-10L-12,10z'],
  78. vertical: ['M0,0L20,0L10,-20z', 'M0,0L20,0L10,20z']
  79. },
  80. pageIconColor: '#2f4554',
  81. pageIconInactiveColor: '#aaa',
  82. pageIconSize: 15,
  83. pageTextStyle: {
  84. color: '#333'
  85. },
  86. animationDurationUpdate: 800
  87. });
  88. return ScrollableLegendModel;
  89. }(LegendModel);
  90. ;
  91. // Do not `ignoreSize` to enable setting {left: 10, right: 10}.
  92. function mergeAndNormalizeLayoutParams(legendModel, target, raw) {
  93. var orient = legendModel.getOrient();
  94. var ignoreSize = [1, 1];
  95. ignoreSize[orient.index] = 0;
  96. mergeLayoutParam(target, raw, {
  97. type: 'box',
  98. ignoreSize: !!ignoreSize
  99. });
  100. }
  101. export default ScrollableLegendModel;