ToolboxModel.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 featureManager from './featureManager.js';
  42. import ComponentModel from '../../model/Component.js';
  43. import tokens from '../../visual/tokens.js';
  44. import { each, extend, merge } from 'zrender/lib/core/util.js';
  45. var ToolboxModel = /** @class */function (_super) {
  46. __extends(ToolboxModel, _super);
  47. function ToolboxModel() {
  48. var _this = _super !== null && _super.apply(this, arguments) || this;
  49. _this.type = ToolboxModel.type;
  50. return _this;
  51. }
  52. ToolboxModel.prototype.init = function (option, parentModel, ecModel) {
  53. // An historical behavior:
  54. // An initial ec option
  55. // chart.setOption( {toolbox: {feature: { featureA: {}, featureB: {}, }} } )
  56. // indicates the declared toolbox features need to be enabled regardless of whether property
  57. // "show" is explicity specified. But the subsequent `setOption` in merge mode requires property
  58. // "show: false" to be explicity specified if intending to remove features, for example:
  59. // chart.setOption( {toolbox: {feature: { featureA: {show: false}, featureC: {} } )
  60. // We keep backward compatibility and perform specific processing to prevent theme
  61. // settings from breaking it.
  62. var toolboxOptionInTheme = ecModel.getTheme().get('toolbox');
  63. var themeFeatureOption = toolboxOptionInTheme ? toolboxOptionInTheme.feature : null;
  64. if (themeFeatureOption) {
  65. // Use extend - the first level of the feature option will be modified later.
  66. this._themeFeatureOption = extend({}, themeFeatureOption);
  67. toolboxOptionInTheme.feature = {};
  68. }
  69. _super.prototype.init.call(this, option, parentModel, ecModel); // merge theme is performed inside it.
  70. if (themeFeatureOption) {
  71. toolboxOptionInTheme.feature = themeFeatureOption; // Recover
  72. }
  73. };
  74. ToolboxModel.prototype.optionUpdated = function () {
  75. each(this.option.feature, function (featureOpt, featureName) {
  76. var themeFeatureOption = this._themeFeatureOption;
  77. var Feature = featureManager.getFeature(featureName);
  78. if (Feature) {
  79. if (Feature.getDefaultOption) {
  80. Feature.defaultOption = Feature.getDefaultOption(this.ecModel);
  81. }
  82. if (themeFeatureOption && themeFeatureOption[featureName]) {
  83. merge(featureOpt, themeFeatureOption[featureName]);
  84. // Follow the previous behavior, theme is only be merged once.
  85. themeFeatureOption[featureName] = null;
  86. }
  87. merge(featureOpt, Feature.defaultOption);
  88. }
  89. }, this);
  90. };
  91. ToolboxModel.type = 'toolbox';
  92. ToolboxModel.layoutMode = {
  93. type: 'box',
  94. ignoreSize: true
  95. };
  96. ToolboxModel.defaultOption = {
  97. show: true,
  98. z: 6,
  99. // zlevel: 0,
  100. orient: 'horizontal',
  101. left: 'right',
  102. top: 'top',
  103. // right
  104. // bottom
  105. backgroundColor: 'transparent',
  106. borderColor: tokens.color.border,
  107. borderRadius: 0,
  108. borderWidth: 0,
  109. padding: tokens.size.m,
  110. itemSize: 15,
  111. itemGap: tokens.size.s,
  112. showTitle: true,
  113. iconStyle: {
  114. borderColor: tokens.color.accent50,
  115. color: 'none'
  116. },
  117. emphasis: {
  118. iconStyle: {
  119. borderColor: tokens.color.accent70
  120. }
  121. },
  122. // textStyle: {},
  123. // feature
  124. tooltip: {
  125. show: false,
  126. position: 'bottom'
  127. }
  128. };
  129. return ToolboxModel;
  130. }(ComponentModel);
  131. export default ToolboxModel;