import { SGItem , SGAreaItem , SGLineItem , SGSymbolItem , SGArcItem , SGRectItem , SGGroupItem , } from '@chart-parts/interfaces' ; import { arc as d3Arc , symbol as d3Symbol , area as d3Area , line as d3Lines , } from 'd3-shape' ; import { Rectangle } from './Rectangle' ; import { symbols } from './symbols' ; const x = ( item ) => item . x || 0 ; const x2 = ( item ) => item . x2 || 0 ; const y = ( item ) => item . y || 0 ; const y2 = ( item ) => item . y2 || 0 ; const w = ( item ) => item . width || 0 ; const h = ( item ) => item . height || 0 ; const sa = ( item ) => item . startAngle || 0 ; const ea = ( item ) => item . endAngle || 0 ; const pa = ( item ) => item . padAngle || 0 ; const ir = ( item ) => item . innerRadius || 0 ; const or = ( item ) => item . outerRadius || 0 ; const cr = ( item ) => item . cornerRadius || 0 ; const def = ( item ) => item . defined == null ? true : item . defined ; param item const symbolSize = ( item ) => ( item . size == null ? 64 : item . size ) ; param item const symbolWidth = ( item ) => item . width == null ? 8 : item . width ; const rendererByArea = ( item ) => symbols ( item . shape || 'circle' ) . byArea ; const rendererByWidth = ( item ) => symbols ( item . shape || 'circle' ) . byWidth ; export const rectShape = new Rectangle ( x , y , w , h , cr ) ; export const arcShape = d3Arc < SGArcItem > ( ) . startAngle ( sa ) . endAngle ( ea ) . padAngle ( pa ) . innerRadius ( ir ) . outerRadius ( or ) . cornerRadius ( cr ) ; export const areahShape = d3Area < SGAreaItem > ( ) . x1 ( x ) . x0 ( x2 ) . y ( y ) . defined ( def ) ; export const areavShape = d3Area < SGAreaItem > ( ) . y1 ( y ) . y0 ( y2 ) . x ( x ) . defined ( def ) ; export const lineShape = d3Lines < SGLineItem > ( ) . x ( x ) . y ( y ) . defined ( def ) ; export const symbolWithArea = d3Symbol < SGSymbolItem > ( ) . type ( rendererByArea ) . size ( symbolSize ) ; export const symbolWithWidth = d3Symbol < SGSymbolItem > ( ) . type ( rendererByWidth ) . size ( symbolWidth ) ;