import { ChartOptions , DEFAULT_HEIGHT , DEFAULT_WIDTH , ItemSpace , } from '@chart-parts/interfaces' ; category export class ChartOptionsManager { public constructor ( private options = { } ) { } public get ariaTitle ( ) : string { return this . options . ariaTitle || 'data visualization using chart-parts' ; } public get ariaDescription ( ) : string { return this . options . ariaDescription || '' ; } public get chartSpace ( ) : ItemSpace { const chartWidth = this . options . width || DEFAULT_WIDTH ; const chartHeight = this . options . height || DEFAULT_HEIGHT ; const paddingLeft = this . paddingLeft ; const paddingRight = this . paddingRight ; const paddingTop = this . paddingTop ; const paddingBottom = this . paddingBottom ; const x = paddingLeft ; const y = paddingTop ; const width = chartWidth - paddingLeft - paddingRight ; const height = chartHeight - paddingTop - paddingBottom ; return { origin : { x , y } , shape : { width , height } , } ; } public get paddingTop ( ) : number { return this . getPadding ( 'top' ) ; } public get paddingBottom ( ) : number { return this . getPadding ( 'bottom' ) ; } public get paddingLeft ( ) : number { return this . getPadding ( 'left' ) ; } public get paddingRight ( ) : number { return this . getPadding ( 'right' ) ; } private getPadding ( name ) { const paddingType = typeof this . options . padding ; if ( paddingType === 'number' ) { return this . options . padding as number ; } else if ( paddingType === 'object' ) { return ( this . options . padding as any ) [ name ] || 0 ; } return 0 ; } }