points.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 { map } from 'zrender/lib/core/util.js';
  41. import createRenderPlanner from '../chart/helper/createRenderPlanner.js';
  42. import { isDimensionStacked } from '../data/helper/dataStackHelper.js';
  43. import { createFloat32Array } from '../util/vendor.js';
  44. export default function pointsLayout(seriesType, forceStoreInTypedArray) {
  45. return {
  46. seriesType: seriesType,
  47. plan: createRenderPlanner(),
  48. reset: function (seriesModel) {
  49. var data = seriesModel.getData();
  50. var coordSys = seriesModel.coordinateSystem;
  51. var pipelineContext = seriesModel.pipelineContext;
  52. var useTypedArray = forceStoreInTypedArray || pipelineContext.large;
  53. if (!coordSys) {
  54. return;
  55. }
  56. var dims = map(coordSys.dimensions, function (dim) {
  57. return data.mapDimension(dim);
  58. }).slice(0, 2);
  59. var dimLen = dims.length;
  60. var stackResultDim = data.getCalculationInfo('stackResultDimension');
  61. if (isDimensionStacked(data, dims[0])) {
  62. dims[0] = stackResultDim;
  63. }
  64. if (isDimensionStacked(data, dims[1])) {
  65. dims[1] = stackResultDim;
  66. }
  67. var store = data.getStore();
  68. var dimIdx0 = data.getDimensionIndex(dims[0]);
  69. var dimIdx1 = data.getDimensionIndex(dims[1]);
  70. return dimLen && {
  71. progress: function (params, data) {
  72. var segCount = params.end - params.start;
  73. var points = useTypedArray && createFloat32Array(segCount * dimLen);
  74. var tmpIn = [];
  75. var tmpOut = [];
  76. for (var i = params.start, offset = 0; i < params.end; i++) {
  77. var point = void 0;
  78. if (dimLen === 1) {
  79. var x = store.get(dimIdx0, i);
  80. // NOTE: Make sure the second parameter is null to use default strategy.
  81. point = coordSys.dataToPoint(x, null, tmpOut);
  82. } else {
  83. tmpIn[0] = store.get(dimIdx0, i);
  84. tmpIn[1] = store.get(dimIdx1, i);
  85. // Let coordinate system to handle the NaN data.
  86. point = coordSys.dataToPoint(tmpIn, null, tmpOut);
  87. }
  88. if (useTypedArray) {
  89. points[offset++] = point[0];
  90. points[offset++] = point[1];
  91. } else {
  92. data.setItemLayout(i, point.slice());
  93. }
  94. }
  95. useTypedArray && data.setLayout('points', points);
  96. }
  97. };
  98. }
  99. };
  100. }
  101. ;