ScatterView.js 4.9 KB

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