Deterministically reduces numeric chart points while retaining endpoints and spikes.
Points are maps containing :sampled_at_ms and :value. Segment metadata is
preserved, allowing the browser renderer to keep recording gaps disconnected.
Summary
Functions
Applies Largest-Triangle-Three-Buckets downsampling to an ordered series.
Types
@type point() :: %{ :sampled_at_ms => integer(), :value => number(), optional(:segment) => non_neg_integer() | String.t() }
Functions
@spec downsample([point()], pos_integer()) :: [point()]
Applies Largest-Triangle-Three-Buckets downsampling to an ordered series.
Examples
iex> points = for value <- 1..10, do: %{sampled_at_ms: value, value: value}
iex> result = BeamConsole.Series.Downsampler.downsample(points, 4)
iex> {length(result), hd(result).value, List.last(result).value}
{4, 1, 10}