Expresso.Element.Chart.Scatter.Legend (expresso v0.1.0)

Copy Markdown View Source

The legends of a scatter plot, in a column at the right of the plot

A scatter plot has up to four legends, from the top:

  • The series, with the symbol and the color of each one.
  • The colors: each category of the color, with its color. When the symbol and the color of each point take the same category, the item also shows the symbol, and the chart has no legend of the symbols.
  • The scale of a color from a number, with its highest and its lowest value.
  • The symbols: each category of the symbol, with its symbol.
  • The sizes: three marks of round sizes, with their values.

The options color_label, symbol_label and size_label give a title to each legend. layout/1 makes the rows, place/2 puts them at the right of the box of the plot, and render/1 draws them.

Summary

Functions

Make the rows of the legends from the assigns of a scatter plot

Put the rows of the legends at the right of the SVG, from the top of the box of the plot

Draw the rows of the legends with the category of the assigns

Return the width that the legends take at the right of the SVG, with a gap before them

Functions

inner_block(name, list)

(macro)

layout(assigns)

@spec layout(map()) :: %{rows: [map()], width: number()}

Make the rows of the legends from the assigns of a scatter plot

Each row has a dy from the top of the legends. An item of a category of the color has the key category, so it goes into the group of its category.

place(legend, box)

@spec place(%{rows: [map()], width: number()}, map()) :: map()

Put the rows of the legends at the right of the SVG, from the top of the box of the plot

render(assigns)

@spec render(map()) :: Phoenix.HTML.safe()

Draw the rows of the legends with the category of the assigns

The key category is nil for the rows outside the groups, or the name of a category of the color for its item.

render_slot(slot, arg)

(macro)

width(map)

@spec width(%{rows: [map()], width: number()}) :: number()

Return the width that the legends take at the right of the SVG, with a gap before them

iex> Expresso.Element.Chart.Scatter.Legend.width(%{rows: [], width: 0})
0