ThumbnailModel.js 4.6 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 ComponentModel from '../../model/Component.js';
  42. import { error } from '../../util/log.js';
  43. import tokens from '../../visual/tokens.js';
  44. import { injectThumbnailBridge } from '../helper/thumbnailBridge.js';
  45. import { ThumbnailBridgeImpl } from './ThumbnailBridgeImpl.js';
  46. var ThumbnailModel = /** @class */function (_super) {
  47. __extends(ThumbnailModel, _super);
  48. function ThumbnailModel() {
  49. var _this = _super !== null && _super.apply(this, arguments) || this;
  50. _this.type = ThumbnailModel.type;
  51. _this.preventAutoZ = true;
  52. return _this;
  53. }
  54. ThumbnailModel.prototype.optionUpdated = function (newCptOption, isInit) {
  55. this._updateBridge();
  56. };
  57. ThumbnailModel.prototype._updateBridge = function () {
  58. var bridge = this._birdge = this._birdge || new ThumbnailBridgeImpl(this);
  59. // Clear all, in case of option changed.
  60. this._target = null;
  61. this.ecModel.eachSeries(function (series) {
  62. injectThumbnailBridge(series, null);
  63. });
  64. if (this.shouldShow()) {
  65. var target = this.getTarget();
  66. // If a component is targeted by more than one thumbnails, simply only the last one works.
  67. injectThumbnailBridge(target.baseMapProvider, bridge);
  68. }
  69. };
  70. ThumbnailModel.prototype.shouldShow = function () {
  71. return this.getShallow('show', true);
  72. };
  73. ThumbnailModel.prototype.getBridge = function () {
  74. return this._birdge;
  75. };
  76. ThumbnailModel.prototype.getTarget = function () {
  77. if (this._target) {
  78. return this._target;
  79. }
  80. // Find by `seriesId`/`seriesIndex`.
  81. var series = this.getReferringComponents('series', {
  82. useDefault: false,
  83. enableAll: false,
  84. enableNone: false
  85. }).models[0];
  86. if (series) {
  87. if (series.subType !== 'graph') {
  88. series = null;
  89. if (process.env.NODE_ENV !== 'production') {
  90. error("series." + series.subType + " is not supported in thumbnail.", true);
  91. }
  92. }
  93. } else {
  94. // If no xxxId and xxxIndex specified, find the first series.graph. If other components,
  95. // such as geo, is supported in future, the default stretagy may be extended.
  96. series = this.ecModel.queryComponents({
  97. mainType: 'series',
  98. subType: 'graph'
  99. })[0];
  100. }
  101. this._target = {
  102. baseMapProvider: series
  103. };
  104. return this._target;
  105. };
  106. ThumbnailModel.type = 'thumbnail';
  107. ThumbnailModel.layoutMode = 'box';
  108. // All the supported components should be added here.
  109. ThumbnailModel.dependencies = ['series', 'geo'];
  110. ThumbnailModel.defaultOption = {
  111. show: true,
  112. right: 1,
  113. bottom: 1,
  114. height: '25%',
  115. width: '25%',
  116. itemStyle: {
  117. // Use echarts option.backgorundColor by default.
  118. borderColor: tokens.color.border,
  119. borderWidth: 2
  120. },
  121. windowStyle: {
  122. borderWidth: 1,
  123. color: tokens.color.neutral30,
  124. borderColor: tokens.color.neutral40,
  125. opacity: 0.3
  126. },
  127. z: 10
  128. };
  129. return ThumbnailModel;
  130. }(ComponentModel);
  131. export { ThumbnailModel };