| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
DataFrame.Display.Web.Chart.Typed
Description
The schema-checked, typed-expression analogue of DataFrame.Display.Web.Chart.
Charts are built over a TypedDataFrame using typed expressions (TExpr,
#col), so column references are checked against the schema at compile time
and the field type follows from the column's Haskell type.
{-# LANGUAGE OverloadedLabels #-}
import qualified DataFrame.Display.Web.Chart.Typed as Plt
-- one-liner
Plt.scatter #age #fare tdf
-- composable grammar
Plt.showChart
( Plt.chart tdf
|> Plt.mark Plt.Boxplot
|> Plt.enc Plt.X #region
|> Plt.enc Plt.Y #value
|> Plt.enc Plt.Color #grp
|> Plt.facet #grp
)
Every combinator delegates to DataFrame.Display.Web.Chart by unwrapping the
typed expression (unTExpr) and frame (unTDF); the cols phantom is erased
at the boundary.
Synopsis
- data Chart (cols :: [(Symbol, Type)])
- chart :: forall (cols :: [(Symbol, Type)]). TypedDataFrame cols -> Chart cols
- data Mark
- data Channel
- data FieldType
- data Agg
- mark :: forall (cols :: [(Symbol, Type)]). Mark -> Chart cols -> Chart cols
- enc :: forall a (cols :: [(Symbol, Type)]). Columnable a => Channel -> TExpr cols a -> Chart cols -> Chart cols
- encAs :: forall a (cols :: [(Symbol, Type)]). Columnable a => Channel -> TExpr cols a -> FieldType -> Chart cols -> Chart cols
- aggregateOn :: forall (cols :: [(Symbol, Type)]). Channel -> Agg -> Chart cols -> Chart cols
- binX :: forall (cols :: [(Symbol, Type)]). Chart cols -> Chart cols
- binY :: forall (cols :: [(Symbol, Type)]). Chart cols -> Chart cols
- facet :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> Chart cols -> Chart cols
- row :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> Chart cols -> Chart cols
- column :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> Chart cols -> Chart cols
- layer :: forall (cols :: [(Symbol, Type)]). [Chart cols] -> Chart cols
- regression :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b) => TExpr cols a -> TExpr cols b -> Chart cols -> Chart cols
- density :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> Chart cols -> Chart cols
- logScale :: forall (cols :: [(Symbol, Type)]). Channel -> Chart cols -> Chart cols
- includeZero :: forall (cols :: [(Symbol, Type)]). Channel -> Bool -> Chart cols -> Chart cols
- title :: forall (cols :: [(Symbol, Type)]). Text -> Chart cols -> Chart cols
- size :: forall (cols :: [(Symbol, Type)]). Int -> Int -> Chart cols -> Chart cols
- toVegaSpec :: forall (cols :: [(Symbol, Type)]). Chart cols -> Value
- toHtml :: forall (cols :: [(Symbol, Type)]). Chart cols -> String
- showChart :: forall (cols :: [(Symbol, Type)]). Chart cols -> IO ()
- scatter :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b) => TExpr cols a -> TExpr cols b -> TypedDataFrame cols -> IO ()
- bar :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TypedDataFrame cols -> IO ()
- histogram :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TypedDataFrame cols -> IO ()
- line :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b) => TExpr cols a -> TExpr cols b -> TypedDataFrame cols -> IO ()
- pie :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TypedDataFrame cols -> IO ()
- box :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TypedDataFrame cols -> IO ()
Chart
data Chart (cols :: [(Symbol, Type)]) Source #
A typed chart: a phantom-cols wrapper over the untyped builder.
chart :: forall (cols :: [(Symbol, Type)]). TypedDataFrame cols -> Chart cols Source #
Start a typed chart from a typed frame.
Re-exported spec vocabulary
Instances
Constructors
| Quantitative | |
| Nominal | |
| Ordinal | |
| Temporal |
Aggregation strategy for grouped/categorical plots.
Building blocks
mark :: forall (cols :: [(Symbol, Type)]). Mark -> Chart cols -> Chart cols Source #
Set the mark type.
enc :: forall a (cols :: [(Symbol, Type)]). Columnable a => Channel -> TExpr cols a -> Chart cols -> Chart cols Source #
Encode a typed expression on a channel (field type inferred from its type).
encAs :: forall a (cols :: [(Symbol, Type)]). Columnable a => Channel -> TExpr cols a -> FieldType -> Chart cols -> Chart cols Source #
Like enc but force the Vega-Lite field type.
aggregateOn :: forall (cols :: [(Symbol, Type)]). Channel -> Agg -> Chart cols -> Chart cols Source #
Apply a declarative aggregation to a channel.
binX :: forall (cols :: [(Symbol, Type)]). Chart cols -> Chart cols Source #
Bin the X (resp. Y) channel.
binY :: forall (cols :: [(Symbol, Type)]). Chart cols -> Chart cols Source #
Bin the X (resp. Y) channel.
facet :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> Chart cols -> Chart cols Source #
Facet into small multiples by a column (alias for column).
row :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> Chart cols -> Chart cols Source #
Facet across columns / down rows.
column :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> Chart cols -> Chart cols Source #
Facet across columns / down rows.
layer :: forall (cols :: [(Symbol, Type)]). [Chart cols] -> Chart cols Source #
Overlay several charts sharing data into a single layered chart.
regression :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b) => TExpr cols a -> TExpr cols b -> Chart cols -> Chart cols Source #
Add a least-squares regression line fitting y on x.
density :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> Chart cols -> Chart cols Source #
Kernel-density estimate of an expression, drawn as an area.
logScale :: forall (cols :: [(Symbol, Type)]). Channel -> Chart cols -> Chart cols Source #
Put a channel on a log scale.
includeZero :: forall (cols :: [(Symbol, Type)]). Channel -> Bool -> Chart cols -> Chart cols Source #
Anchor (True) or release (False) a channel's scale at zero.
title :: forall (cols :: [(Symbol, Type)]). Text -> Chart cols -> Chart cols Source #
Set the chart title.
size :: forall (cols :: [(Symbol, Type)]). Int -> Int -> Chart cols -> Chart cols Source #
Set the chart size in pixels.
Rendering
toVegaSpec :: forall (cols :: [(Symbol, Type)]). Chart cols -> Value Source #
The Vega-Lite spec as an aeson Value (escape hatch for advanced use / hvega).
toHtml :: forall (cols :: [(Symbol, Type)]). Chart cols -> String Source #
A self-contained HTML snippet embedding the chart.
showChart :: forall (cols :: [(Symbol, Type)]). Chart cols -> IO () Source #
Render the chart to a temp file and open it in the default browser.
One-shot convenience plots
scatter :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b) => TExpr cols a -> TExpr cols b -> TypedDataFrame cols -> IO () Source #
Scatter plot of two typed expressions.
bar :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TypedDataFrame cols -> IO () Source #
Count of rows per category, as bars.
histogram :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TypedDataFrame cols -> IO () Source #
Histogram of a numeric expression.
line :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b) => TExpr cols a -> TExpr cols b -> TypedDataFrame cols -> IO () Source #
Line chart of y over x.
pie :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TypedDataFrame cols -> IO () Source #
Pie chart counting rows per category.
box :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TypedDataFrame cols -> IO () Source #
Box-and-whisker plot of a numeric expression.