highcharts
Version:
JavaScript charting framework
236 lines (221 loc) • 9.12 kB
JavaScript
// SPDX-License-Identifier: LicenseRef-Highcharts
/**
* @license Highcharts Gantt JS v13.0.1 (2026-08-17)
* @module highcharts/modules/static-scale
* @requires highcharts
*
* StaticScale
*
* (c) 2016-2026 Highsoft AS
* Author: Torstein Hønsi, Lars A. V. Cabrera
*
* A commercial license may be required depending on use,
* see www.highcharts.com/license
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(root["_Highcharts"]);
else if(typeof define === 'function' && define.amd)
define("highcharts/modules/static-scale", ["highcharts/highcharts"], function (amd1) {return factory(amd1);});
else if(typeof exports === 'object')
exports["highcharts/modules/static-scale"] = factory(root["_Highcharts"]);
else
root["Highcharts"] = factory(root["Highcharts"]);
})(typeof window === 'undefined' ? this : window, (__WEBPACK_EXTERNAL_MODULE__944__) => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 944
(module) {
module.exports = __WEBPACK_EXTERNAL_MODULE__944__;
/***/ }
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ const __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ const cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ const module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ const getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter/value functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ if(Array.isArray(definition)) {
/******/ var i = 0;
/******/ while(i < definition.length) {
/******/ var key = definition[i++];
/******/ var binding = definition[i++];
/******/ if(!__webpack_require__.o(exports, key)) {
/******/ if(binding === 0) {
/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
/******/ } else {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
/******/ }
/******/ } else if(binding === 0) { i++; }
/******/ }
/******/ } else {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/************************************************************************/
let __webpack_exports__ = {};
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"default": () => (/* binding */ static_scale_src)
});
// EXTERNAL MODULE: external {"amd":["highcharts/highcharts"],"commonjs":["highcharts"],"commonjs2":["highcharts"],"root":["Highcharts"]}
var highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_ = __webpack_require__(944);
var highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_default = /*#__PURE__*/__webpack_require__.n(highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_);
;// ./code/es-modules/Extensions/StaticScale.js
/* *
*
* (c) 2016-2026 Highsoft AS
* Author: Torstein Hønsi, Lars Cabrera
*
* Integration of this software requires a license.
* - For commercial use, see www.highcharts.com/license
* - For non-commercial, see www.highcharts.com/license-eula
*
*
* */
const { composed } = (highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_default());
/* *
*
* Composition
*
* */
/** @internal */
function composeStaticScale(AxisClass, ChartClass) {
if ((0,highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_.pushUnique)(composed, 'StaticScale')) {
const chartProto = ChartClass.prototype;
(0,highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_.addEvent)(AxisClass, 'afterSetOptions', onAxisAfterSetOptions);
chartProto.adjustHeight = chartAdjustHeight;
(0,highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_.addEvent)(ChartClass, 'render', chartProto.adjustHeight);
}
}
/** @internal */
function onAxisAfterSetOptions() {
const chartOptions = this.chart.userOptions.chart;
if (!this.horiz &&
(0,highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_.isNumber)(this.options.staticScale) &&
(!chartOptions?.height ||
chartOptions.scrollablePlotArea?.minHeight)) {
this.staticScale = this.options.staticScale;
}
}
/** @internal */
function chartAdjustHeight() {
const chart = this;
if (chart.redrawTrigger !== 'adjustHeight') {
for (const axis of (chart.axes || [])) {
const chart = axis.chart, staticScale = axis.options.staticScale;
if (axis.staticScale &&
staticScale &&
(0,highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_.defined)(axis.min) &&
(0,highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_.defined)(axis.max)) {
let height = (axis.brokenAxis?.unitLength ??
(axis.max + axis.tickInterval - axis.min)) * staticScale;
// Minimum height is 1 x staticScale.
height = Math.max(height, staticScale);
const diff = height - chart.plotHeight;
if (!chart.scrollablePixelsY && Math.abs(diff) >= 1) {
chart.plotHeight = height;
chart.redrawTrigger = 'adjustHeight';
chart.setSize(void 0, chart.chartHeight + diff, chart.initiatedScale ? void 0 : false);
}
// Make sure clip rects have the right height before initial
// animation.
axis.series.forEach(function (series) {
const clipRect = series.sharedClipKey &&
chart.sharedClips[series.sharedClipKey];
if (clipRect) {
clipRect.attr(chart.inverted ? {
width: chart.plotHeight
} : {
height: chart.plotHeight
});
}
});
}
}
this.initiatedScale = true;
}
this.redrawTrigger = void 0;
}
/* *
*
* API Options
*
* */
/**
* For vertical axes only. Setting the static scale ensures that each tick unit
* is translated into a fixed pixel height. For example, setting the static
* scale to 24 results in each Y axis category taking up 24 pixels, and the
* height of the chart adjusts. Adding or removing items will make the chart
* resize.
*
* @sample {gantt} gantt/xrange-series/demo/
* X-range series with static scale
* @sample {highcharts} highcharts/xaxis/staticscale
* Static scale on X axis (horizontal bar chart)
*
* @requires modules/static-scale
* @type {number}
* @default 50
* @since 6.2.0
* @product highcharts highstock gantt
* @apioption xAxis.staticScale
*/
''; // Keeps doclets above in JS file
;// ./code/es-modules/masters/modules/static-scale.src.js
const G = (highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_default());
composeStaticScale(G.Axis, G.Chart);
/* harmony default export */ const static_scale_src = ((highcharts_commonjs_highcharts_commonjs2_highcharts_root_Highcharts_default()));
__webpack_exports__ = __webpack_exports__["default"];
/******/ return __webpack_exports__;
/******/ })()
;
});