What a channel of a chart shows: the field of the data it reads, and
how. x, y, color and size are channels.
A channel is given in a short form or in full:
Fude.bar(sales, x: :region, y: :revenue)
Fude.bar(sales, x: :region, y: {:sum, :revenue})
Fude.line(visits, x: {:month, :day}, y: {:count, :id})
Fude.histogram(orders, x: {:bin, :total})
Fude.bar(sales, x: :region, y: [field: :revenue, aggregate: :sum, format: :compact])
Fude.rule(y: 1000)- an atom or a string is a field;
{aggregate, field}aggregates the field::count,:sum,:mean,:median,:min,:maxor:distinct;{unit, field}takes a unit of a time::year,:quarter,:month,:week,:day,:houror:minute;{:bin, field}puts the numbers of a field in bins;- a number is a constant, as the height of a rule;
- a keyword list is the full form, with the keys below.
Keys
:field- the field of the data.:type-:number,:time,:categoryor:ordinal; learned from the data when not given.:aggregate- see above.:time- a unit of a time, see above.:bin-true, or a keyword list with:count(about how many bins) or:step(the width of a bin).:sort- the order of a field's categories::ascending,:descending,:x,:y,:"-x"or:"-y"(by another channel, the minus for descending), or a list of the categories in order.:format- how the browser writes the values::number,:integer,:percent,:compact,{:currency, "EUR"},:bytes, or a unit of a time for times.:title- the title of the axis or the legend; the field's name when not given,falsefor none.:scale- a keyword list::type(:linear,:log,:sqrt),:domain([min, max], or the categories),:zero(whether a number scale starts at zero),:nice.:stack-:zero(the default of bars and areas with a color),:normalize(to 100%),:centerorfalse.:value- a constant instead of a field.
Summary
Functions
Whether the channel reads a field (and not a constant).
A channel from its short form or its full form (see above). Raises an
ArgumentError that names the channel and the value when it is neither.
The title of the channel's axis or legend: its own, or its field's name.
Types
@type aggregate() :: :count | :sum | :mean | :median | :min | :max | :distinct
@type t() :: %Fude.Channel{ aggregate: aggregate() | nil, bin: boolean() | map() | nil, field: String.t() | nil, format: atom() | {atom(), String.t()} | nil, scale: map() | nil, sort: atom() | [term()] | nil, stack: atom() | false | nil, time: time_unit() | nil, title: String.t() | false | nil, type: type() | nil, value: term() }
@type time_unit() :: :year | :quarter | :month | :week | :day | :hour | :minute
@type type() :: :number | :time | :category | :ordinal
Functions
Whether the channel reads a field (and not a constant).
A channel from its short form or its full form (see above). Raises an
ArgumentError that names the channel and the value when it is neither.
The title of the channel's axis or legend: its own, or its field's name.