Turn an AshDyan.Result into chart-library-ready shapes.
AshDyan.run/1 returns a stable labels/series structure. This module maps
that structure onto common chart types and serializes it for popular charting
libraries, so a client can render a chart without knowing AshDyan's internals.
Chart types
:bar— categorical counts / grouped aggregates.:line— time-bucketed series, percentiles, or any ordered axis.:area— like:linebut filled (good for cumulative / time series).:pie/:donut— single-series frequency or aggregate breakdowns.:histogram— binned numeric distribution (the:histogramresult type).:scatter— (x, y) pairs when a result has exactly two series.
Recommendation
recommend/1 picks a sensible default chart type from the result's type and
shape, so a generic UI can render something reasonable without per-call config.
Serialization
to_chartjs/2— returns a Chart.jsdata/optionsmap (JSON-encodable).to_echarts/2— returns an EChartsoptionmap (JSON-encodable).
Summary
Functions
Build a chart-ready map for the given chart type.
Pick a default chart type for a result.
Serialize a result to a Chart.js data/options map.
Serialize a result to an ECharts option map.
Types
Functions
@spec build(AshDyan.Result.t(), chart_type() | nil) :: map()
Build a chart-ready map for the given chart type.
Returns %{type: chart_type, labels: [...], series: [...], options: %{}}. If
chart_type is omitted, recommend/1 is used.
@spec recommend(AshDyan.Result.t()) :: chart_type()
Pick a default chart type for a result.
:frequency→:bar(or:piewhen there is a single series).:aggregate→:bar(or:piefor a single series).:time_bucket→:line.:percentile→:line.:histogram→:histogram.
@spec to_chartjs(AshDyan.Result.t(), chart_type() | nil) :: map()
Serialize a result to a Chart.js data/options map.
chart_type is optional (defaults to recommend/1). The returned map is
JSON-encodable via Jason.encode!/1.
@spec to_echarts(AshDyan.Result.t(), chart_type() | nil) :: map()
Serialize a result to an ECharts option map.
chart_type is optional (defaults to recommend/1). The returned map is
JSON-encodable via Jason.encode!/1.