ScrollableLegendModel.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. import tokens from '../../visual/tokens.js';
  45. var ScrollableLegendModel = /** @class */function (_super) {
  46. __extends(ScrollableLegendModel, _super);
  47. function ScrollableLegendModel() {
  48. var _this = _super !== null && _super.apply(this, arguments) || this;
  49. _this.type = ScrollableLegendModel.type;
  50. return _this;
  51. }
  52. /**
  53. * @param {number} scrollDataIndex
  54. */
  55. ScrollableLegendModel.prototype.setScrollDataIndex = function (scrollDataIndex) {
  56. this.option.scrollDataIndex = scrollDataIndex;
  57. };
  58. ScrollableLegendModel.prototype.init = function (option, parentModel, ecModel) {
  59. var inputPositionParams = getLayoutParams(option);
  60. _super.prototype.init.call(this, option, parentModel, ecModel);
  61. mergeAndNormalizeLayoutParams(this, option, inputPositionParams);
  62. };
  63. /**
  64. * @override
  65. */
  66. ScrollableLegendModel.prototype.mergeOption = function (option, ecModel) {
  67. _super.prototype.mergeOption.call(this, option, ecModel);
  68. mergeAndNormalizeLayoutParams(this, this.option, option);
  69. };
  70. ScrollableLegendModel.type = 'legend.scroll';
  71. ScrollableLegendModel.defaultOption = inheritDefaultOption(LegendModel.defaultOption, {
  72. scrollDataIndex: 0,
  73. pageButtonItemGap: 5,
  74. pageButtonGap: null,
  75. pageButtonPosition: 'end',
  76. pageFormatter: '{current}/{total}',
  77. pageIcons: {
  78. horizontal: ['M0,0L12,-10L12,10z', 'M0,0L-12,-10L-12,10z'],
  79. vertical: ['M0,0L20,0L10,-20z', 'M0,0L20,0L10,20z']
  80. },
  81. pageIconColor: tokens.color.accent50,
  82. pageIconInactiveColor: tokens.color.accent10,
  83. pageIconSize: 15,
  84. pageTextStyle: {
  85. color: tokens.color.tertiary
  86. },
  87. animationDurationUpdate: 800
  88. });
  89. return ScrollableLegendModel;
  90. }(LegendModel);
  91. ;
  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;