linesLayout.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. /* global Float32Array */
  41. import createRenderPlanner from '../helper/createRenderPlanner.js';
  42. import { error } from '../../util/log.js';
  43. var linesLayout = {
  44. seriesType: 'lines',
  45. plan: createRenderPlanner(),
  46. reset: function (seriesModel) {
  47. var coordSys = seriesModel.coordinateSystem;
  48. if (!coordSys) {
  49. if (process.env.NODE_ENV !== 'production') {
  50. error('The lines series must have a coordinate system.');
  51. }
  52. return;
  53. }
  54. var isPolyline = seriesModel.get('polyline');
  55. var isLarge = seriesModel.pipelineContext.large;
  56. return {
  57. progress: function (params, lineData) {
  58. var lineCoords = [];
  59. if (isLarge) {
  60. var points = void 0;
  61. var segCount = params.end - params.start;
  62. if (isPolyline) {
  63. var totalCoordsCount = 0;
  64. for (var i = params.start; i < params.end; i++) {
  65. totalCoordsCount += seriesModel.getLineCoordsCount(i);
  66. }
  67. points = new Float32Array(segCount + totalCoordsCount * 2);
  68. } else {
  69. points = new Float32Array(segCount * 4);
  70. }
  71. var offset = 0;
  72. var pt = [];
  73. for (var i = params.start; i < params.end; i++) {
  74. var len = seriesModel.getLineCoords(i, lineCoords);
  75. if (isPolyline) {
  76. points[offset++] = len;
  77. }
  78. for (var k = 0; k < len; k++) {
  79. pt = coordSys.dataToPoint(lineCoords[k], false, pt);
  80. points[offset++] = pt[0];
  81. points[offset++] = pt[1];
  82. }
  83. }
  84. lineData.setLayout('linesPoints', points);
  85. } else {
  86. for (var i = params.start; i < params.end; i++) {
  87. var itemModel = lineData.getItemModel(i);
  88. var len = seriesModel.getLineCoords(i, lineCoords);
  89. var pts = [];
  90. if (isPolyline) {
  91. for (var j = 0; j < len; j++) {
  92. pts.push(coordSys.dataToPoint(lineCoords[j]));
  93. }
  94. } else {
  95. pts[0] = coordSys.dataToPoint(lineCoords[0]);
  96. pts[1] = coordSys.dataToPoint(lineCoords[1]);
  97. var curveness = itemModel.get(['lineStyle', 'curveness']);
  98. if (+curveness) {
  99. pts[2] = [(pts[0][0] + pts[1][0]) / 2 - (pts[0][1] - pts[1][1]) * curveness, (pts[0][1] + pts[1][1]) / 2 - (pts[1][0] - pts[0][0]) * curveness];
  100. }
  101. }
  102. lineData.setItemLayout(i, pts);
  103. }
  104. }
  105. }
  106. };
  107. }
  108. };
  109. export default linesLayout;