import { MarkType , SGItem , SGMark } from '@chart-parts/interfaces' ; import { createItem , createMark } from './factory' ; export class MarkBuilder { private itemsValue : SGItem [ ] = [ ] ; private clipValue ? : boolean ; private interactiveValue ? : boolean ; private roleValue ? : string ; private nameValue ? : string ; private zIndexValue ? : number ; public constructor ( public markType ) { } public items ( ... values ) { this . itemsValue . push ( ... values . map ( itemProps => createItem ( this . markType , itemProps ) ) ) ; return this ; } public clip ( value ? ) { this . clipValue = value ; return this ; } public interactive ( value ? ) { this . interactiveValue = value ; return this ; } public role ( value ? ) { this . roleValue = value ; return this ; } public name ( value ? ) { this . nameValue = value ; return this ; } public zIndex ( value ? ) { this . zIndexValue = value ; return this ; } public build ( ) { const result = createMark ( this . markType , this . itemsValue ) ; result . clip = this . clipValue ; result . interactive = this . interactiveValue ; result . role = this . roleValue ; result . name = this . nameValue ; result . zIndex = this . zIndexValue ; return result ; } }