ScatterView.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 SymbolDraw from '../helper/SymbolDraw.js';
  42. import LargeSymbolDraw from '../helper/LargeSymbolDraw.js';
  43. import pointsLayout from '../../layout/points.js';
  44. import ChartView from '../../view/Chart.js';
  45. import { getIncrementalId } from '../../util/model.js';
  46. import { createCoordSysClipAreaSimply } from '../helper/createClipPathFromCoordSys.js';
  47. var ScatterView = /** @class */function (_super) {
  48. __extends(ScatterView, _super);
  49. function ScatterView() {
  50. var _this = _super !== null && _super.apply(this, arguments) || this;
  51. _this.type = ScatterView.type;
  52. return _this;
  53. }
  54. ScatterView.prototype.render = function (seriesModel, ecModel, api) {
  55. var data = seriesModel.getData();
  56. var symbolDraw = this._updateSymbolDraw(data, seriesModel);
  57. symbolDraw.updateData(data, createSymbolDrawOpt(seriesModel));
  58. this._finished = true;
  59. };
  60. ScatterView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
  61. var data = seriesModel.getData();
  62. var symbolDraw = this._updateSymbolDraw(data, seriesModel);
  63. symbolDraw.incrementalPrepareUpdate(data);
  64. this._finished = false;
  65. };
  66. ScatterView.prototype.incrementalRender = function (taskParams, seriesModel, ecModel) {
  67. this._symbolDraw.incrementalUpdate(taskParams, seriesModel.getData(), getIncrementalId(seriesModel), createSymbolDrawOpt(seriesModel));
  68. this._finished = taskParams.end === seriesModel.getData().count();
  69. };
  70. /**
  71. * See also VIEW_COORD_SYS_ANIMATION
  72. */
  73. ScatterView.prototype.updateTransform = function (seriesModel, ecModel, api) {
  74. var data = seriesModel.getData();
  75. // Must mark group dirty and make sure the incremental layer will be cleared
  76. // PENDING
  77. this.group.dirty();
  78. if (!this._finished) {
  79. // FIXME: _finished checking is unnecessary?
  80. return {
  81. update: true
  82. };
  83. } else {
  84. var res = pointsLayout('').reset(seriesModel, ecModel, api);
  85. if (res.progress) {
  86. res.progress({
  87. start: 0,
  88. end: data.count(),
  89. count: data.count()
  90. }, data);
  91. }
  92. this._symbolDraw.updateLayout(createSymbolDrawOpt(seriesModel));
  93. }
  94. };
  95. ScatterView.prototype.eachRendered = function (cb) {
  96. this._symbolDraw && this._symbolDraw.eachRendered(cb);
  97. };
  98. ScatterView.prototype._updateSymbolDraw = function (data, seriesModel) {
  99. var symbolDraw = this._symbolDraw;
  100. var pipelineContext = seriesModel.pipelineContext;
  101. var isLargeDraw = pipelineContext.large;
  102. if (!symbolDraw || isLargeDraw !== this._isLargeDraw) {
  103. symbolDraw && symbolDraw.remove();
  104. symbolDraw = this._symbolDraw = isLargeDraw ? new LargeSymbolDraw() : new SymbolDraw();
  105. this._isLargeDraw = isLargeDraw;
  106. this.group.removeAll();
  107. }
  108. this.group.add(symbolDraw.group);
  109. return symbolDraw;
  110. };
  111. ScatterView.prototype.remove = function (ecModel, api) {
  112. this._symbolDraw && this._symbolDraw.remove(true);
  113. this._symbolDraw = null;
  114. };
  115. ScatterView.prototype.dispose = function () {};
  116. ScatterView.type = 'scatter';
  117. return ScatterView;
  118. }(ChartView);
  119. function createSymbolDrawOpt(seriesModel) {
  120. return {
  121. // TODO
  122. // If this parameter should be a shape or a bounding volume
  123. // shape will be more general.
  124. // But bounding volume like bounding rect will be much faster in the contain calculation
  125. clipShape: createCoordSysClipAreaSimply(seriesModel)
  126. };
  127. }
  128. export default ScatterView;