ScatterView.js 5.0 KB

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