# `Fude.Data`
[🔗](https://github.com/hattoriai/fude/blob/v0.1.0/lib/fude/data.ex#L1)

The data of a chart, in columns: each field with its type and its
values, in the order of the rows.

Fude takes:

  * a list of maps, with atom or string keys;
  * a map of `:columns` (names) and `:rows` (lists of values in the
    columns' order), as a query result has them (`Postgrex.Result`,
    `Lotus.Result`), with atom or string keys.

The values become those the browser draws: a `Decimal` a number, a
`Date`, `NaiveDateTime` or `DateTime` a time (milliseconds since 1970,
a date at its midnight in UTC), and anything else that is not a number
text. `nil` stays: it is a gap.

# `field`

```elixir
@type field() :: %{name: String.t(), type: type(), unit: :day | :month | :year | nil}
```

# `t`

```elixir
@type t() :: %Fude.Data{
  columns: %{required(String.t()) =&gt; [term()]},
  count: non_neg_integer(),
  fields: [field()],
  names: [String.t()]
}
```

# `type`

```elixir
@type type() :: :number | :time | :category
```

# `column`

```elixir
@spec column(t(), String.t()) :: [term()]
```

The values of a field.

# `field`

```elixir
@spec field(t(), String.t()) :: field() | nil
```

The field of a name, or `nil`.

# `names`

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

The names of the fields, in order.

# `new`

```elixir
@spec new(term(), [String.t()] | nil) :: t()
```

The data in columns. With `only` (names), it reads only those fields: a
chart reads the few it draws of a query's many. Raises an
`ArgumentError` when the data is none of the forms above.

# `rows`

```elixir
@spec rows(term()) :: [map()]
```

The data as rows: a list of maps with string keys, as `Fude.Spec.dump/2` puts it.

# `where`

```elixir
@spec where(t(), String.t(), term()) :: t()
```

The rows whose field has a value.

---

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