# `GanttEx.LinkPath`
[🔗](https://github.com/rocket4ce/gantt_ex/blob/v0.1.0/lib/gantt_ex/link_path.ex#L1)

Routes dependency arrows between two task bars.

Links are drawn with orthogonal segments, like DHTMLX Gantt: the line leaves
the source edge horizontally, travels vertically in a "lane" next to the
bars and enters the target edge horizontally, ending with an arrow head.
When the target edge is behind the source edge, the line detours through the
boundary between rows.

Boxes describe the *row* of each task: `x` and `width` of the bar, `y` (top
of the row) and the `row_height`.

    iex> source = %{x: 0, width: 100, y: 0}
    iex> target = %{x: 150, width: 80, y: 36}
    iex> path = GanttEx.LinkPath.route(source, target, :finish_to_start, row_height: 36)
    iex> path.points
    [{100, 18.0}, {112, 18.0}, {112, 54.0}, {144, 54.0}]
    iex> path.d
    "M100 18L112 18L112 54L144 54"

    iex> source = %{x: 100, width: 100, y: 0}
    iex> target = %{x: 50, width: 40, y: 36}
    iex> GanttEx.LinkPath.route(source, target, :finish_to_start, row_height: 36).points
    [{200, 18.0}, {212, 18.0}, {212, 36}, {38, 36}, {38, 54.0}, {44, 54.0}]

# `box`

```elixir
@type box() :: %{x: number(), width: number(), y: number()}
```

# `point`

```elixir
@type point() :: {number(), number()}
```

# `t`

```elixir
@type t() :: %{
  points: [point()],
  arrow: [point()],
  d: String.t(),
  arrow_d: String.t()
}
```

# `format_number`

```elixir
@spec format_number(number()) :: String.t()
```

Formats a coordinate with at most one decimal.

    iex> GanttEx.LinkPath.format_number(12.0)
    "12"

    iex> GanttEx.LinkPath.format_number(12.34)
    "12.3"

# `route`

```elixir
@spec route(box(), box(), GanttEx.Link.type(), keyword()) :: t()
```

Computes the path of a link of `type` from `source` to `target`.

## Options

  * `:row_height` - height of a row in pixels. Defaults to `36`.
  * `:gap` - horizontal distance between a bar edge and the vertical lane. Defaults to `12`.
  * `:arrow` - size of the arrow head. Defaults to `6`.

# `to_d`

```elixir
@spec to_d([point()]) :: String.t()
```

Converts points into an SVG path.

    iex> GanttEx.LinkPath.to_d([{0, 0}, {10.25, 5}])
    "M0 0L10.3 5"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
