Skip to content

Latest commit

 

History

History
35 lines (35 loc) · 797 Bytes

arc_draw.md

File metadata and controls

35 lines (35 loc) · 797 Bytes
const arcDraw = (mode, target) => {
  d3.selectAll('.datamaps-subunit')
    .on('click', function(d, i) {
      let data = map.options.data[d.id];
      let w = data.totalNum ? data.totalNum : 0;
      if (mode === 'Exports') {
        if (d.id !== target) {
          map.arc(
            [
              {
                origin: target,
                destination: d.id,
                strokeWidth: 2 * Math.trunc(Math.log(w + 1))
              }
            ]
          );
        }
      } else {
        if (d.id !== 'USA') {
          map.arc(
            [
              {
                origin: d.id,
                destination: target,
                strokeWidth: 2 * Math.trunc(Math.log(w + 1))
              }
            ]
          );
        }
      }
    }
  );
};