highcharts
Version:
JavaScript charting framework
107 lines (106 loc) • 3.14 kB
JavaScript
/* *
*
* (c) 2010-2026 Highsoft AS
* Author: Torstein Hønsi
*
* Extension to the Series object in 3D charts.
*
* A commercial license may be required depending on use.
* See www.highcharts.com/license
*
*
* */
;
import H from '../Globals.js';
const { composed } = H;
import Math3D from '../Math3D.js';
const { perspective } = Math3D;
import Series from '../Series/Series.js';
import { addEvent, extend, isNumber, merge, pick, pushUnique } from '../../Shared/Utilities.js';
/* *
*
* Class
*
* */
/** @internal */
class Series3D extends Series {
/* *
*
* Static Functions
*
* */
static compose(SeriesClass) {
if (pushUnique(composed, 'Core.Series3D')) {
addEvent(SeriesClass, 'afterTranslate', function () {
if (this.chart.is3d()) {
this.translate3dPoints();
}
});
extend(SeriesClass.prototype, {
translate3dPoints: Series3D.prototype.translate3dPoints
});
}
}
/* *
*
* Functions
*
* */
/**
* Translate the plotX, plotY properties and add plotZ.
* @internal
*/
translate3dPoints() {
const series = this, seriesOptions = series.options, chart = series.chart, zAxis = pick(series.zAxis, chart.options.zAxis[0]), rawPoints = [], rawPointsX = [], stack = seriesOptions.stacking ?
(isNumber(seriesOptions.stack) ? seriesOptions.stack : 0) :
series.index || 0;
let projectedPoint, zValue;
series.zPadding = stack *
(seriesOptions.depth || 0 + (seriesOptions.groupZPadding || 1));
series.points.forEach((rawPoint) => {
if (zAxis?.translate) {
zValue = zAxis.logarithmic && zAxis.val2lin ?
zAxis.val2lin(rawPoint.z) :
rawPoint.z; // #4562
rawPoint.plotZ = zAxis.translate(zValue);
rawPoint.isInside = rawPoint.isInside ?
(zValue >= zAxis.min &&
zValue <= zAxis.max) :
false;
}
else {
rawPoint.plotZ = series.zPadding;
}
rawPoint.axisXpos = rawPoint.plotX;
rawPoint.axisYpos = rawPoint.plotY;
rawPoint.axisZpos = rawPoint.plotZ;
rawPoints.push({
x: rawPoint.plotX,
y: rawPoint.plotY,
z: rawPoint.plotZ
});
rawPointsX.push(rawPoint.plotX || 0);
});
series.rawPointsX = rawPointsX;
const projectedPoints = perspective(rawPoints, chart, true);
series.points.forEach((rawPoint, i) => {
projectedPoint = projectedPoints[i];
rawPoint.plotX = projectedPoint.x;
rawPoint.plotY = projectedPoint.y;
rawPoint.plotZ = projectedPoint.z;
});
}
}
/* *
*
* Static Properties
*
* */
Series3D.defaultOptions = merge(Series.defaultOptions);
/* *
*
* Default Export
*
* */
/** @internal */
export default Series3D;