function resolveSettings(comp) {
  const domain = comp.scale.domain();
  let data = { items: [] };
  const dock = comp.settings.layout.dock;
  if (comp.scale.type === 'threshold-color') {
    const fields = comp.scale.data().fields;
    const sourceField = fields[0];
    let formatter = (v) => String(v);

    if (comp.settings.formatter) {
      formatter = comp.chart.formatter(comp.settings.formatter);
    } else if (sourceField) {
      formatter = sourceField.formatter();
    }

    for (let i = 0; i < domain.length - 1; i++) {
      const it = {
        value: domain[i],
        label: `${formatter(domain[i])} - < ${formatter(domain[i + 1])}`,
      };
      if (sourceField) {
        it.source = {
          field: sourceField.id(),
        };
      }
      data.items.push(it);
    }
    const orientation = dock === 'top' || dock === 'bottom' ? 'horizontal' : 'vertical';

    if (orientation === 'vertical') {
      data.items.reverse();
    }
  } else {
    const labels = comp.scale.labels ? comp.scale.labels() : null;
    data.items = domain.map((d, idx) => {
      const datum = comp.scale.datum ? extend({}, comp.scale.datum(d)) : { value: d };
      datum.value = d;

      if (comp.scale.label) {
        datum.label = comp.scale.label(d);
      } else if (labels) {
        datum.label = labels[idx];
      }

      return datum;
    });
  }

  const title = comp.resolver.resolve({
    data: {
      fields: comp.scale.data().fields,
    },
    defaults: extend(true, {}, DEFAULT_SETTINGS.title, comp.style.title),
    settings: comp.settings.settings.title,
  });

  const layout = comp.resolver.resolve({
    data: {
      fields: comp.scale.data().fields,
    },
    defaults: DEFAULT_SETTINGS.layout,
    settings: comp.settings.settings.layout,
  });

  const labels = comp.resolver.resolve({
    data,
    defaults: extend(true, {}, DEFAULT_SETTINGS.item.label, comp.style.item.label),
    settings: (comp.settings.settings.item || {}).label,
  });

  const shapeSettings = extend(true, {}, (comp.settings.settings.item || {}).shape);

  if (typeof shapeSettings.fill === 'undefined' && comp.settings.scale) {
    shapeSettings.fill = {
      scale: comp.settings.scale,
    };
  }

  const symbols = comp.resolver.resolve({
    data,
    defaults: extend(true, {}, DEFAULT_SETTINGS.item.shape, comp.style.item.shape),
    settings: shapeSettings,
  });

  const items = comp.resolver.resolve({
    data,
    defaults: extend(
      true,
      {},
      {
        show: DEFAULT_SETTINGS.item.show,
      }
    ),
    settings: {
      show: (comp.settings.settings.item || {}).show,
    },
  });

  function range(item, i) {
    let v = item.data.value;
    let next = domain[i + 1];
    item.data.value = [v, next];
  }

  if (comp.scale.type === 'threshold-color') {
    const orientation = dock === 'top' || dock === 'bottom' ? 'horizontal' : 'vertical';

    if (orientation === 'vertical') {
      items.items.reverse().forEach(range);
      items.items.reverse();
    } else {
      items.items.forEach(range);
    }
  }

  return {
    title,
    labels,
    symbols,
    items,
    layout,
  };
}
/**
 * Resolve settings based on input, defaults, and data
 *
 * @ignore
 * @param {legendComponent} comp - The component instance
 */
Resolve settings based on input, defaults, and data
@ignore
@param {legendComponent} comp - The component instance
Resolve settings based on input defaults and data @ignore @param { legendComponent } comp - The component instance
function resolveSettings(comp) {
  const domain = comp.scale.domain();
  let data = { items: [] };
  const dock = comp.settings.layout.dock;
  if (comp.scale.type === 'threshold-color') {
    const fields = comp.scale.data().fields;
    const sourceField = fields[0];
    let formatter = (v) => String(v);
    if (comp.settings.formatter) {
      formatter = comp.chart.formatter(comp.settings.formatter);
    } else if (sourceField) {
      formatter = sourceField.formatter();
    }
    for (let i = 0; i < domain.length - 1; i++) {
      const it = {
        value: domain[i],
        label: `${formatter(domain[i])} - < ${formatter(domain[i + 1])}`,
      };
      if (sourceField) {
        it.source = {
          field: sourceField.id(),
        };
      }
      data.items.push(it);
    }
    const orientation = dock === 'top' || dock === 'bottom' ? 'horizontal' : 'vertical';
    if (orientation === 'vertical') {
      data.items.reverse();
    }
  } else {
    const labels = comp.scale.labels ? comp.scale.labels() : null;
    data.items = domain.map((d, idx) => {
      const datum = comp.scale.datum ? extend({}, comp.scale.datum(d)) : { value: d };
      datum.value = d;
      if (comp.scale.label) {
        datum.label = comp.scale.label(d);
      } else if (labels) {
        datum.label = labels[idx];
      }
      return datum;
    });
  }
  const title = comp.resolver.resolve({
    data: {
      fields: comp.scale.data().fields,
    },
    defaults: extend(true, {}, DEFAULT_SETTINGS.title, comp.style.title),
    settings: comp.settings.settings.title,
  });
  const layout = comp.resolver.resolve({
    data: {
      fields: comp.scale.data().fields,
    },
    defaults: DEFAULT_SETTINGS.layout,
    settings: comp.settings.settings.layout,
  });
  const labels = comp.resolver.resolve({
    data,
    defaults: extend(true, {}, DEFAULT_SETTINGS.item.label, comp.style.item.label),
    settings: (comp.settings.settings.item || {}).label,
  });
  const shapeSettings = extend(true, {}, (comp.settings.settings.item || {}).shape);
  if (typeof shapeSettings.fill === 'undefined' && comp.settings.scale) {
    shapeSettings.fill = {
      scale: comp.settings.scale,
    };
  }
  const symbols = comp.resolver.resolve({
    data,
    defaults: extend(true, {}, DEFAULT_SETTINGS.item.shape, comp.style.item.shape),
    settings: shapeSettings,
  });
  const items = comp.resolver.resolve({
    data,
    defaults: extend(
      true,
      {},
      {
        show: DEFAULT_SETTINGS.item.show,
      }
    ),
    settings: {
      show: (comp.settings.settings.item || {}).show,
    },
  });
  function range(item, i) {
    let v = item.data.value;
    let next = domain[i + 1];
    item.data.value = [v, next];
  }
  if (comp.scale.type === 'threshold-color') {
    const orientation = dock === 'top' || dock === 'bottom' ? 'horizontal' : 'vertical';
    if (orientation === 'vertical') {
      items.items.reverse().forEach(range);
      items.items.reverse();
    } else {
      items.items.forEach(range);
    }
  }
  return {
    title,
    labels,
    symbols,
    items,
    layout,
  };
}
function resolveSettings ( comp ) { const domain = comp . scale . domain ( ) ; let data = { items : [ ] } ; const dock = comp . settings . layout . dock ; if ( comp . scale . type === 'threshold-color' ) { const fields = comp . scale . data ( ) . fields ; const sourceField = fields [ 0 ] ; let formatter = ( v ) => String ( v ) ; if ( comp . settings . formatter ) { formatter = comp . chart . formatter ( comp . settings . formatter ) ; } else if ( sourceField ) { formatter = sourceField . formatter ( ) ; } for ( let i = 0 ; i < domain . length - 1 ; i ++ ) { const it = { value : domain [ i ] , label : ` ${ formatter ( domain [ i ] ) } ${ formatter ( domain [ i + 1 ] ) } ` , } ; if ( sourceField ) { it . source = { field : sourceField . id ( ) , } ; } data . items . push ( it ) ; } const orientation = dock === 'top' || dock === 'bottom' ? 'horizontal' : 'vertical' ; if ( orientation === 'vertical' ) { data . items . reverse ( ) ; } } else { const labels = comp . scale . labels ? comp . scale . labels ( ) : null ; data . items = domain . map ( ( d , idx ) => { const datum = comp . scale . datum ? extend ( { } , comp . scale . datum ( d ) ) : { value : d } ; datum . value = d ; if ( comp . scale . label ) { datum . label = comp . scale . label ( d ) ; } else if ( labels ) { datum . label = labels [ idx ] ; } return datum ; } ) ; } const title = comp . resolver . resolve ( { data : { fields : comp . scale . data ( ) . fields , } , defaults : extend ( true , { } , DEFAULT_SETTINGS . title , comp . style . title ) , settings : comp . settings . settings . title , } ) ; const layout = comp . resolver . resolve ( { data : { fields : comp . scale . data ( ) . fields , } , defaults : DEFAULT_SETTINGS . layout , settings : comp . settings . settings . layout , } ) ; const labels = comp . resolver . resolve ( { data , defaults : extend ( true , { } , DEFAULT_SETTINGS . item . label , comp . style . item . label ) , settings : ( comp . settings . settings . item || { } ) . label , } ) ; const shapeSettings = extend ( true , { } , ( comp . settings . settings . item || { } ) . shape ) ; if ( typeof shapeSettings . fill === 'undefined' && comp . settings . scale ) { shapeSettings . fill = { scale : comp . settings . scale , } ; } const symbols = comp . resolver . resolve ( { data , defaults : extend ( true , { } , DEFAULT_SETTINGS . item . shape , comp . style . item . shape ) , settings : shapeSettings , } ) ; const items = comp . resolver . resolve ( { data , defaults : extend ( true , { } , { show : DEFAULT_SETTINGS . item . show , } ) , settings : { show : ( comp . settings . settings . item || { } ) . show , } , } ) ; function range ( item , i ) { let v = item . data . value ; let next = domain [ i + 1 ] ; item . data . value = [ v , next ] ; } if ( comp . scale . type === 'threshold-color' ) { const orientation = dock === 'top' || dock === 'bottom' ? 'horizontal' : 'vertical' ; if ( orientation === 'vertical' ) { items . items . reverse ( ) . forEach ( range ) ; items . items . reverse ( ) ; } else { items . items . forEach ( range ) ; } } return { title , labels , symbols , items , layout , } ; }
Resolve settings based on input, defaults, and data
 @ignore
 @param {legendComponent} comp - The component instance
Resolve settings based on input defaults and data @ignore @param { legendComponent } comp - The component instance