src/component/legend.js
function updateLegendGroup(selection, viewBox, orient) {
  const widthFactor = 0.2;
  const scaleF = viewBox.right * widthFactor / 120;
  const o = orient.split('-');
  const viewW = viewBox.right;
  const viewH = viewBox.bottom;
  const legW = viewW * widthFactor;
  const legH = legW * 50 / 120;
  const posX = {left: legW / 10, right: viewW - legW - (legW / 10)}[o[1]];
  const posY = {top: legH / 10, bottom: viewH - legH - (legH / 10)}[o[0]];
  selection.attr('transform',
                 `translate(${posX}, ${posY}) scale(${scaleF})`);
}
function updateLegendGroup(selection, viewBox, orient) {
  const widthFactor = 0.2;
  const scaleF = viewBox.right * widthFactor / 120;
  const o = orient.split('-');
  const viewW = viewBox.right;
  const viewH = viewBox.bottom;
  const legW = viewW * widthFactor;
  const legH = legW * 50 / 120;
  const posX = {left: legW / 10, right: viewW - legW - (legW / 10)}[o[1]];
  const posY = {top: legH / 10, bottom: viewH - legH - (legH / 10)}[o[0]];
  selection.attr('transform',
                 `translate(${posX}, ${posY}) scale(${scaleF})`);
}
function updateLegendGroup ( selection , viewBox , orient ) { const widthFactor = 0.2 ; const scaleF = viewBox . right * widthFactor / 120 ; const o = orient . split ( '-' ) ; const viewW = viewBox . right ; const viewH = viewBox . bottom ; const legW = viewW * widthFactor ; const legH = legW * 50 / 120 ; const posX = { left : legW / 10 , right : viewW - legW - ( legW / 10 ) } [ o [ 1 ] ] ; const posY = { top : legH / 10 , bottom : viewH - legH - ( legH / 10 ) } [ o [ 0 ] ] ; selection . attr ( 'transform' , ` ${ posX } ${ posY } ${ scaleF } ` ) ; }
Legend group component
@param {d3.selection} selection - selection of group container (svg:g)
Legend group component