Functions for building graphs and charts. A chart consists of one more graphs. Graphs come in various flavors, notably line and scatter.
In this module, Svg
means TypedSvg.Core.Svg
{ xMin : Basics.Float
, xMax : Basics.Float
, yMin : Basics.Float
, yMax : Basics.Float
}
A box containing data of the form List (Float, Float)
{ width : Basics.Float
, height : Basics.Float
, padding : Basics.Float
}
Format determines the height, width, and appearance of the rendered chart
{ graphType : GraphType
, r : Basics.Float
, g : Basics.Float
, b : Basics.Float
, boundingBox : BoundingBox
, data : Data
}
A Graph consists of data in the form of List (Float, Float)
,
a bounding box, a choice of color, and a GraphType, e.g, Line
or Scatter
.
{ boundingBox : BoundingBox
, confidence : Maybe Basics.Float
, data : List Graph
}
A chart consists of a boundig box and a list of Graphs.
A chart is rendered to SVG by the view
function.
boundingBox : Data -> BoundingBox
Compute a bounding box from data, where
type alias Data =
List ( Float, Float )
emptyGraph : Graph
graph : GraphType -> Basics.Float -> Basics.Float -> Basics.Float -> Data -> Graph
Make a graph of given GraphType and given color r, g, b from the given data. where
type alias Data =
List ( Float, Float )
lineGraph : Format -> Graph -> TypedSvg.Core.Svg msg
Render graph data to SVG as a broken line.
meanLine : Format -> Graph -> TypedSvg.Core.Svg msg
Draw a line through mean values of the data.
scatter : Format -> Graph -> TypedSvg.Core.Svg msg
Render graph data to SVG as a scatter plot.
errorBars : Format -> Basics.Float -> Data -> TypedSvg.Core.Svg msg
Render error bars with given confidence level for the given data as SVG
view : Format -> Maybe (TypedSvg.Core.Svg msg) -> StatChart -> TypedSvg.Core.Svg msg
Convert a chart to (typed) SVG. Parameters:
Format
: determines the dimensions and appearance of the output
Maybe (Svg mg)
: this is an "annotation," which maybeNothing
orJust svgValue
, wheresvgValue
is any value of typeSvg msg
.
HereSvg
meand TypedSvg.Core.Svg
.
StatChart
: the chart to be rendered
One use of annotations is to add error bars to a chart. See
./examples/src/Hubble.elm
chart : Graph -> StatChart
Make a chart out of a graph
addGraph : Graph -> StatChart -> StatChart
Add a graph to an existing StatChart