# `Visualize.Shape.Needle`
[🔗](https://github.com/dcoai/Visualize/blob/v0.8.3/lib/visualize/shape/needle.ex#L1)

Needle generator: one filled pointer per datum from the hub to its angle, as long as
its length — a gauge's indicator, a compass needle (spec/04 §16, #392).

`angle/2` is in the domain units of the radial scale given to `scale/2` (radians without
one); `length/2`, `inner_radius/2`, `width/2` and `tail/2` are pixels. Each datum's
path is a tapered shape from the base at the hub to the tip, closed; `hub_path/2` is
the hub circle the pointer turns about.

## Examples

    reading = Visualize.Scale.linear() |> Visualize.Scale.domain([0, 100]) |> Visualize.Scale.range([-2.0944, 2.0944])

    needle =
      Visualize.Shape.Needle.new()
      |> Visualize.Shape.Needle.scale(reading)
      |> Visualize.Shape.Needle.angle(:value)
      |> Visualize.Shape.Needle.length(120)
      |> Visualize.Shape.Needle.tail(12)

    [path] = Visualize.Shape.Needle.generate_path(needle, [%{value: 42}])

# `cap`

```elixir
@type cap() :: :point | :round | :flat
```

# `t`

```elixir
@type t() :: %Visualize.Shape.Needle{
  angle: Visualize.Shape.Line.accessor() | nil,
  cap: cap(),
  hub: Visualize.Shape.Line.accessor() | nil,
  inner_radius: Visualize.Shape.Line.accessor(),
  length: Visualize.Shape.Line.accessor() | nil,
  scale: struct() | nil,
  tail: Visualize.Shape.Line.accessor(),
  width: Visualize.Shape.Line.accessor()
}
```

# `angle`

```elixir
@spec angle(t(), Visualize.Shape.Line.accessor()) :: t()
```

Sets the angle accessor, in the scale's domain units (radians without a scale)

# `cap`

```elixir
@spec cap(t(), cap()) :: t()
```

Sets the tip: `:point`, `:round` or `:flat`

# `generate`

```elixir
@spec generate(t(), Visualize.Data.Table.source()) :: [String.t()]
```

Returns the list of SVG path-data strings, one pointer per datum

# `generate_path`

```elixir
@spec generate_path(t(), Visualize.Data.Table.source()) :: [Visualize.IR.Path.t()]
```

Returns the list of `IR.Path`, one pointer per datum: from the base corner behind the
hub, round the tail, to the other corner, then to the tip as the cap says, closed.

# `hub`

```elixir
@spec hub(t(), Visualize.Shape.Line.accessor() | nil) :: t()
```

Sets the hub circle's radius accessor; `nil` means the width

# `hub_path`

```elixir
@spec hub_path(t(), term()) :: Visualize.IR.Path.t()
```

Returns the hub circle's `IR.Path` for a datum, radius `hub` (the width when `nil`)

# `inner_radius`

```elixir
@spec inner_radius(t(), Visualize.Shape.Line.accessor()) :: t()
```

Sets where the pointer starts, in pixels (default `0`)

# `length`

```elixir
@spec length(t(), Visualize.Shape.Line.accessor()) :: t()
```

Sets the tip's radius accessor, in pixels

# `new`

```elixir
@spec new() :: t()
```

Creates a needle generator reading tuple elements 0 and 1 as angle and length

# `scale`

```elixir
@spec scale(t(), struct() | nil) :: t()
```

Sets the radial scale the angles map through; `nil` means radians

# `tail`

```elixir
@spec tail(t(), Visualize.Shape.Line.accessor()) :: t()
```

Sets how far the pointer extends behind the hub, in pixels (default `0`)

# `width`

```elixir
@spec width(t(), Visualize.Shape.Line.accessor()) :: t()
```

Sets the base width accessor, in pixels (default `6`)

---

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