export const PIo180 = Math . PI / 180 ; export function getRadius ( d ) { return d * PIo180 ; } export function p2c ( x , y , radius , angle ) { const radians = getRadius ( angle - 90 ) ; return { x : x + ( radius * Math . cos ( radians ) ) , y : y + ( radius * Math . sin ( radians ) ) , } ; } export function arc2path ( x , y , radius , startAngle , endAngle ) { endAngle -= 0.0001 ; const end = p2c ( x , y , radius , startAngle ) ; const start = p2c ( x , y , radius , endAngle ) ; const large = endAngle - startAngle > 180 ? 1 : 0 ; return [ 'M' , start . x , start . y , 'A' , radius , radius , 0 , large , 0 , end . x , end . y ] . join ( ' ' ) ; } export function currentMax2circleDegrees ( current , max ) { return current / max * 360 ; }