src/draw.js
/**
  * Configures generators objects used in the plugins to work with
  * scaled accessors
  *
  * @param object Generator
  * @param object Configuration
  * @param object layer state (see draw loop)
  * @param object Visualization config
  * @return Scaled accessor name
  */
Configures generators objects used in the plugins to work with
scaled accessors


Configures generators objects used in the plugins to work with scaled accessors
configGen(gen, cfg, layerState, row) {
    let genMethods = Object.keys(gen);
    let cfgMethods = Object.keys(cfg).filter(d => (d in gen && typeof gen[d] == 'function') || (d.startsWith && d.startsWith('d3.')) || !genMethods.length);
    cfgMethods.forEach((item, i) => {
      if (typeof cfg[item] == 'object' && !Array.isArray(cfg[item])) {
        if (item.startsWith('d3.')) {
          let m = new Function(`return ${item}()`)(); 
          this.configGen(m, cfg[item], layerState); 
          gen.arg = m;
          gen(m); 
        } else {
          this.configGen(gen[item], cfg[item], layerState);
        }
      } else if (item in layerState.sa) { 
        gen[item](layerState.sa[item]); 
      } else if (`(${item})` in layerState.sa)
        gen[item](layerState.sa[`(${item})`](row)); 
      else
        gen[item](cfg[item]); 
    });
    return gen;
  }
configGen ( gen , cfg , layerState , row ) { let genMethods = Object . keys ( gen ) ; let cfgMethods = Object . keys ( cfg ) . filter ( d => ( d in gen && typeof gen [ d ] == 'function' ) || ( d . startsWith && d . startsWith ( 'd3.' ) ) || ! genMethods . length ) ; cfgMethods . forEach ( ( item , i ) => { if ( typeof cfg [ item ] == 'object' && ! Array . isArray ( cfg [ item ] ) ) { if ( item . startsWith ( 'd3.' ) ) { let m = new Function ( ` ${ item } ` ) ( ) ; this . configGen ( m , cfg [ item ] , layerState ) ; gen . arg = m ; gen ( m ) ; } else { this . configGen ( gen [ item ] , cfg [ item ] , layerState ) ; } } else if ( item in layerState . sa ) { gen [ item ] ( layerState . sa [ item ] ) ; } else if ( ` ${ item } ` in layerState . sa ) gen [ item ] ( layerState . sa [ ` ${ item } ` ] ( row ) ) ; else gen [ item ] ( cfg [ item ] ) ; } ) ; return gen ; }
Configures generators objects used in the plugins to work with
 scaled accessors
Configures generators objects used in the plugins to work with scaled accessors
// genVal(item, true); // init sub generator // cfg sub generator // add to parent generator // BUG: deep cfgGen fails. Eg: projection['d3.mercator'].center:scaled-accesssor // pass the accessor // or resolve it // (genVal(cfg[item]));