{"size": 683, "ext": "js", "max_stars_repo_path": "src/sankeyLinkHorizontal.js", "max_stars_repo_name": "kiln/d3-sankey", "max_stars_repo_stars_event_min_datetime": "2020-05-06T01:55:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-08T10:37:16.000Z", "max_issues_repo_path": "src/sankeyLinkHorizontal.js", "max_issues_repo_name": "kiln/d3-sankey", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/sankeyLinkHorizontal.js", "max_forks_repo_name": "kiln/d3-sankey", "max_forks_repo_forks_event_min_datetime": "2020-05-06T01:55:40.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-23T07:01:27.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 26.2692307692, "max_line_length": 105, "alphanum_fraction": 0.6896046852}
import {linkHorizontal} from "d3-shape";

var MIN_OFFSET = 0.01;

function horizontalSource(d) {
  return [d.source.x1, d.y0];
}

function horizontalTarget(d) {
  // If y1 approximately equals y0, add a pixel offset so gradients work with default gradientUnits
  // See https://stackoverflow.com/questions/21638169/svg-line-with-gradient-stroke-wont-display-straight
  var y1 = d.y1;
  var height = y1 - d.y0;
  if (Math.abs(height) < MIN_OFFSET) {
    if (height >= 0) y1 = d.y0 + MIN_OFFSET;
    else y1 = d.y0 - MIN_OFFSET;
  }
  return [d.target.x0, y1];
}

export default function() {
  return linkHorizontal()
      .source(horizontalSource)
      .target(horizontalTarget);
}
