Area3DSeries.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* *
  2. *
  3. * (c) 2010-2021 Grzegorz Blachliński
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. 'use strict';
  11. import Math3D from '../Extensions/Math3D.js';
  12. var perspective = Math3D.perspective;
  13. import SeriesRegistry from '../Core/Series/SeriesRegistry.js';
  14. var _a = SeriesRegistry.seriesTypes, AreaSeriesClass = _a.area, LineSeriesClass = _a.line;
  15. import U from '../Core/Utilities.js';
  16. var pick = U.pick, wrap = U.wrap;
  17. /* eslint-disable no-invalid-this */
  18. wrap(AreaSeriesClass.prototype, 'getGraphPath', function (proceed) {
  19. var series = this, svgPath = proceed.apply(series, [].slice.call(arguments, 1));
  20. // Do not do this if the chart is not 3D
  21. if (!series.chart.is3d()) {
  22. return svgPath;
  23. }
  24. var getGraphPath = LineSeriesClass.prototype.getGraphPath, graphPath = [], options = series.options, stacking = options.stacking, bottomPath, bottomPoints = [], graphPoints = [], i, areaPath, connectNulls = pick(// #10574
  25. options.connectNulls, stacking === 'percent'), translatedThreshold = Math.round(// #10909
  26. series.yAxis.getThreshold(options.threshold)), options3d;
  27. if (series.rawPointsX) {
  28. for (var i_1 = 0; i_1 < series.points.length; i_1++) {
  29. bottomPoints.push({
  30. x: series.rawPointsX[i_1],
  31. y: options.stacking ? series.points[i_1].yBottom : translatedThreshold,
  32. z: series.zPadding
  33. });
  34. }
  35. }
  36. options3d = series.chart.options.chart.options3d;
  37. bottomPoints = perspective(bottomPoints, series.chart, true).map(function (point) {
  38. return { plotX: point.x, plotY: point.y, plotZ: point.z };
  39. });
  40. if (series.group && options3d && options3d.depth && options3d.beta) {
  41. // Markers should take the global zIndex of series group.
  42. if (series.markerGroup) {
  43. series.markerGroup.add(series.group);
  44. series.markerGroup.attr({
  45. translateX: 0,
  46. translateY: 0
  47. });
  48. }
  49. series.group.attr({
  50. zIndex: Math.max(1, (options3d.beta > 270 || options3d.beta < 90) ?
  51. options3d.depth - Math.round(series.zPadding || 0) :
  52. Math.round(series.zPadding || 0))
  53. });
  54. }
  55. bottomPoints.reversed = true;
  56. bottomPath = getGraphPath.call(series, bottomPoints, true, true);
  57. if (bottomPath[0] && bottomPath[0][0] === 'M') {
  58. bottomPath[0] = ['L', bottomPath[0][1], bottomPath[0][2]];
  59. }
  60. if (series.areaPath) {
  61. // Remove previously used bottomPath and add the new one.
  62. areaPath = series.areaPath.splice(0, series.areaPath.length / 2).concat(bottomPath);
  63. areaPath.xMap = series.areaPath.xMap; // Use old xMap in the new areaPath
  64. series.areaPath = areaPath;
  65. graphPath = getGraphPath.call(series, graphPoints, false, connectNulls);
  66. }
  67. return svgPath;
  68. });