1/* * 2 * 3 * (c) 2010-2024 Torstein Honsi 4 * 5 * License: www.highcharts.com/license 6 * 7 * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!! 8 * 9 * */ 10'use strict'; 11import H from '../Core/Globals.js'; 12const { deg2rad } = H; 13import Series from '../Core/Series/Series.js'; 14import U from '../Core/Utilities.js'; 15const { fireEvent, isNumber, pick, relativeLength } = U; 16/** 17 * @private 18 */ 19var CenteredUtilities; 20(function (CenteredUtilities) { 21 /* * 22 * 23 * Declarations 24 * 25 * */ 26 /* * 27 * 28 * Functions 29 * 30 * */ 31 /* eslint-disable valid-jsdoc */ 32 /** 33 * Get the center of the pie based on the size and center options relative 34 * to the plot area. Borrowed by the polar and gauge series types. 35 * 36 * @private 37 * @function Highcharts.CenteredSeriesMixin.getCenter 38 */ 39 function getCenter() { 40 const options = this.options, chart = this.chart, slicingRoom = 2 * (options.slicedOffset || 0), plotWidth = chart.plotWidth - 2 * slicingRoom, plotHeight = chart.plotHeight - 2 * slicingRoom, centerOption = options.center, smallestSize = Math.min(plotWidth, plotHeight), thickness = options.thickness; 41 let handleSlicingRoom, size = options.size, innerSize = options.innerSize || 0, i, value; 42 if (typeof size === 'string') { 43 size = parseFloat(size); 44 } 45 if (typeof innerSize === 'string') { 46 innerSize = parseFloat(innerSize); 47 } 48 const positions = [ 49 pick(centerOption?.[0], '50%'), 50 pick(centerOption?.[1], '50%'), 51 // Prevent from negative values 52 pick(size && size < 0 ? void 0 : options.size, '100%'), 53 pick(innerSize && innerSize < 0 ? void 0 : options.innerSize || 0, '0%') 54 ]; 55 // No need for inner size in angular (gauges) series but still required 56 // for pie series 57 if (chart.angular && !(this instanceof Series)) { 58 positions[3] = 0; 59 } 60 for (i = 0; i < 4; ++i) { 61 value = positions[i]; 62 handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value)); 63 // I == 0: centerX, relative to width 64 // i == 1: centerY, relative to height 65 // i == 2: size, relative to smallestSize 66 // i == 3: innerSize, relative to size 67 positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) + (handleSlicingRoom ? slicingRoom : 0); 68 } 69 // Inner size cannot be larger than size (#3632) 70 if (positions[3] > positions[2]) { 71 positions[3] = positions[2]; 72 } 73 // Thickness overrides innerSize, need to be less than pie size (#6647) 74 if (isNumber(thickness) && 75 thickness * 2 < positions[2] && thickness > 0) { 76 positions[3] = positions[2] - thickness * 2; 77 } 78 fireEvent(this, 'afterGetCenter', { positions }); 79 return positions; 80 } 81 CenteredUtilities.getCenter = getCenter; 82 /** 83 * GetStartAndEndRadians - Calculates start and end angles in radians. 84 * Used in series types such as pie and sunburst. 85 * 86 * @private 87 * @function Highcharts.CenteredSeriesMixin.getStartAndEndRadians 88 * 89 * @param {number} [start] 90 * Start angle in degrees. 91 * 92 * @param {number} [end] 93 * Start angle in degrees. 94 * 95 * @return {Highcharts.RadianAngles}
96 * Returns an object containing start and end angles as radians. 97 */ 98 function getStartAndEndRadians(start, end) { 99 const startAngle = isNumber(start) ? start : 0, // Must be a number 100 endAngle = ((isNumber(end) && // Must be a number 101 end > startAngle && // Must be larger than the start angle 102 // difference must be less than 360 degrees 103 (end - startAngle) < 360) ? 104 end : 105 startAngle + 360), correction = -90; 106 return { 107 start: deg2rad * (startAngle + correction), 108 end: deg2rad * (endAngle + correction) 109 }; 110 } 111 CenteredUtilities.getStartAndEndRadians = getStartAndEndRadians; 112})(CenteredUtilities || (CenteredUtilities = {})); 113/* * 114 * 115 * Default Export 116 * 117 * */ 118export default CenteredUtilities; 119/* * 120 * 121 * API Declarations 122 * 123 * */ 124/** 125 * @private 126 * @interface Highcharts.RadianAngles 127 */ /** 128* @name Highcharts.RadianAngles#end 129* @type {number} 130*/ /** 131* @name Highcharts.RadianAngles#start 132* @type {number} 133*/ 134''; // Keeps doclets above in JS file
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.