ScrollableLegendModel.js 3.8 KB

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