'use strict' ; import type SeriesOptions from '../Core/Series/SeriesOptions' ; import H from '../Core/Globals.js' ; const { deg2rad } = H ; import Series from '../Core/Series/Series.js' ; import U from '../Core/Utilities.js' ; const { isNumber , pick , relativeLength } = U ; private namespace CenteredUtilities { export interface CenteredSeries extends Series { options : CenteredSeriesOptions ; } export interface CenteredSeriesOptions extends SeriesOptions { center ? : Array < ( number | string | null ) > ; innerSize ? : ( number | string ) ; size ? : ( number | string ) ; slicedOffset ? : number ; } export interface RadianAngles { end : number ; start : number ; } private function export function getCenter ( this ) { 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 as any , smallestSize = Math . min ( plotWidth , plotHeight ) ; let handleSlicingRoom , size = options . size , innerSize = options . innerSize || 0 , i , value ; if ( typeof size === 'string' ) { size = parseFloat ( size ) ; } if ( typeof innerSize === 'string' ) { innerSize = parseFloat ( innerSize ) ; } const positions = [ pick ( centerOption [ 0 ] as any , '50%' as any ) , pick ( centerOption [ 1 ] as any , '50%' as any ) , pick ( size && size < 0 ? void 0 : options . size , '100%' ) , pick ( innerSize && innerSize < 0 ? void 0 : options . innerSize || 0 , '0%' ) ] ; if ( chart . angular && ! ( this instanceof Series ) ) { positions [ 3 ] = 0 ; } for ( i = 0 ; i < 4 ; ++ i ) { value = positions [ i ] ; handleSlicingRoom = i < 2 || ( i === 2 && /%$/ . test ( value as any ) ) ; positions [ i ] = relativeLength ( value , [ plotWidth , plotHeight , smallestSize , positions [ 2 ] ] [ i ] ) + ( handleSlicingRoom ? slicingRoom : 0 ) ; } if ( positions [ 3 ] > positions [ 2 ] ) { positions [ 3 ] = positions [ 2 ] ; } return positions ; } private function param { number } start param { number } end return { Highcharts . RadianAngles } export function getStartAndEndRadians ( start ? , end ? ) { const startAngle = isNumber ( start ) ? start : 0 , endAngle = ( ( isNumber ( end ) && end > startAngle && ( end - startAngle ) < 360 ) ? end : startAngle + 360 ) , correction = - 90 ; return { start : deg2rad * ( startAngle + correction ) , end : deg2rad * ( endAngle + correction ) } ; } } export default CenteredUtilities ; private interface name type { number } name type { number } '' ;