UNPKG

highcharts

Version:
128 lines (127 loc) 3.51 kB
/* * * * (c) 2010-2026 Highsoft AS * Author: Torstein Hønsi * * Integration of this software requires a license. * - For commercial use, see www.highcharts.com/license * - For non-commercial, see www.highcharts.com/license-eula * * * */ 'use strict'; import Axis from './Axis.js'; import D from '../Defaults.js'; const { defaultOptions } = D; import { splat, merge, addEvent } from '../../Shared/Utilities.js'; /* * * * Functions * * */ /** @internal */ function chartAddZAxis(options) { return new ZAxis(this, options); } /** * Get the Z axis in addition to the default X and Y. * @internal */ function onChartAfterCreateAxes() { const zAxisOptions = this.options.zAxis = splat(this.options.zAxis || {}); if (!this.is3d()) { return; } this.zAxis = []; zAxisOptions.forEach((axisOptions) => { this.addZAxis(axisOptions).setScale(); }); } /* * * * Class * * */ /** * 3D axis for z coordinates. */ class ZAxis extends Axis { constructor() { /* * * * Static Properties * * */ super(...arguments); this.isZAxis = true; } /** @internal */ static compose(ChartClass) { const chartProto = ChartClass.prototype; if (!chartProto.addZAxis) { defaultOptions.zAxis = merge(defaultOptions.xAxis, { offset: 0, lineWidth: 0 }); chartProto.addZAxis = chartAddZAxis; chartProto.collectionsWithInit.zAxis = [chartProto.addZAxis]; chartProto.collectionsWithUpdate.push('zAxis'); addEvent(ChartClass, 'afterCreateAxes', onChartAfterCreateAxes); } } /* * * * Constructor * * */ init(chart, userOptions) { // #14793, this used to be set on the prototype this.isZAxis = true; super.init(chart, userOptions, 'zAxis'); } /* * * * Functions * * */ /** @internal */ getSeriesExtremes() { this.hasVisibleSeries = false; // Reset properties in case we're redrawing (#3353) this.dataMin = this.dataMax = this.ignoreMinPadding = (this.ignoreMaxPadding = void 0); if (this.stacking) { this.stacking.buildStacks(); } // Loop through this axis' series this.series.forEach((series) => { if (series.reserveSpace()) { let threshold = series.options.threshold; this.hasVisibleSeries = true; // Validate threshold in logarithmic axes if (this.positiveValuesOnly && threshold <= 0) { threshold = void 0; } const zData = [...series.getColumn('z', false, true)] // When z is not defined, render in the 0 plane .map((z) => z || 0); if (zData.length) { this.dataMin = Math.min(this.dataMin ?? (zData[0] || 0), Math.min.apply(null, zData)); this.dataMax = Math.max(this.dataMax ?? (zData[0] || 0), Math.max.apply(null, zData)); } } }); } /** @internal */ setAxisSize() { const chart = this.chart; super.setAxisSize(); this.width = this.len = chart.options.chart.options3d?.depth || 0; this.right = chart.chartWidth - this.width - this.left; } } /* * * * Default Export * * */ export default ZAxis;