Area3DSeries.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 = 0; i < series.points.length; i++) {
  29. bottomPoints.push({
  30. x: series.rawPointsX[i],
  31. y: options.stacking ? series.points[i].yBottom : translatedThreshold,
  32. z: series.zPadding
  33. });
  34. }
  35. }
  36. if (series.chart.options && series.chart.options.chart) {
  37. options3d = series.chart.options.chart.options3d;
  38. bottomPoints = perspective(bottomPoints, series.chart, true).map(function (point) {
  39. return { plotX: point.x, plotY: point.y, plotZ: point.z };
  40. });
  41. if (series.group && options3d && options3d.depth && options3d.beta) {
  42. // Markers should take the global zIndex of series group.
  43. if (series.markerGroup) {
  44. series.markerGroup.add(series.group);
  45. series.markerGroup.attr({
  46. translateX: 0,
  47. translateY: 0
  48. });
  49. }
  50. series.group.attr({
  51. zIndex: Math.max(1, (options3d.beta > 270 || options3d.beta < 90) ?
  52. options3d.depth - Math.round(series.zPadding || 0) :
  53. Math.round(series.zPadding || 0))
  54. });
  55. }
  56. }
  57. bottomPoints.reversed = true;
  58. bottomPath = getGraphPath.call(series, bottomPoints, true, true);
  59. if (bottomPath[0] && bottomPath[0][0] === 'M') {
  60. bottomPath[0] = ['L', bottomPath[0][1], bottomPath[0][2]];
  61. }
  62. if (series.areaPath) {
  63. // Remove previously used bottomPath and add the new one.
  64. areaPath = series.areaPath.splice(0, series.areaPath.length / 2).concat(bottomPath);
  65. areaPath.xMap = series.areaPath.xMap; // Use old xMap in the new areaPath
  66. series.areaPath = areaPath;
  67. graphPath = getGraphPath.call(series, graphPoints, false, connectNulls);
  68. }
  69. return svgPath;
  70. });