View Source Plox.Scale protocol (Plox v0.2.1)

A protocol for graph scales.

Any graph scale must implement this protocol in order to be used by the Plox.graph component.

Summary

Types

t()

Any struct that implements this protocol

Functions

Converts a specific scale value to a number within the requested range

Returns an enumerable of the "labeled values" in a scale

Types

t()

@type t() :: any()

Any struct that implements this protocol

Built in implementations are:

Functions

convert_to_range(scale, value, to_range)

@spec convert_to_range(scale :: t(), any(), Range.t()) :: number()

Converts a specific scale value to a number within the requested range

The destination range must be a valid integer range.

values(scale, opts)

@spec values(scale :: t(), opts :: map()) :: Enumerable.t()

Returns an enumerable of the "labeled values" in a scale

Note: the returned values don't necessarily represent all the values in the scale, just the values meant to be labeled and rendered on the corresponding axis. e.g. the final value might not be equal to the scale's configured max.