jxxcarlson/elm-graph/1.0.1

NOTE: the latest version is 3.1.0

Graph

Graph is a bare-bones package for rendering data as line and bar charts, both as HTML and as SVG.

For examples, see the REAdME. For a demo, see https://jxxcarlson.github.io/app/gamblers_ruin.html

lineChart : GraphAttributes -> List Point -> Html msg

Render a list of points (pairs of floats) to Html as a line chart. using the parameters of GraphAttributes. GraphAttributes controls the appearance of the graph -- width, height, color, tick marks on the axes. The x-coordinates of the data are assumed to be in increasing order.

lineChartWithDataWindow : DataWindow -> GraphAttributes -> List Point -> Html msg

This function is like lineChart, but with the additional DataWindow parameter. A DataWindow defines the range of x and y coordinates that are displayed. In lineChart, the DataWindow is deduced from the data presented.

barChart : GraphAttributes -> List Float -> Html msg

Render a list of numbers to Html as a bar chart using the parameters of GraphAttributes.

type alias Point =
( Float, Float )

The data to be graphed by Graph.asHtml is a List Point.

type alias DataWindow =
{ xMax : Float
, xMin : Float
, yMax : Float
, yMin : Float
}

A DataWindow is a rectangle which determines the x and y ranges of the data to be displayed..

type alias GraphAttributes =
{ graphHeight : Float
, graphWidth : Float
, options : List Option
}

A GraphAttributes value defines the size on the screen occupied by the graph and the color of the line.

type Option
= Color String
| XTickmarks Int
| YTickmarks Int
| DeltaX Float

Use the options field to customize the line chart. Examples: (1) [Color "blue"] makes the charted line blue (2) [Color "blue", XTickmarks 10, YTickmarks 5] places 10 tick marks along the x-axis and 5 tick marks along the y-axis, (3) options = [ ] produces a bare-bones graph.

The DeltaX option is used to specify the distnce from the leading edge of one bar to the next in bar graph.

lineChartAsSVG : GraphAttributes -> List Point -> Svg msg

Render a list of points to SVG as a line chart using the parameters of GraphAttributes.

lineChartAsSVGWithDataWindow : DataWindow -> GraphAttributes -> List Point -> Svg msg

Render a list of points to Svg as a line chart using the parameters of GraphAttributes and DataWindow.

barChartAsSVG : GraphAttributes -> List Float -> Svg msg

Render a list of numbers to Svg as a bar chart using the parameters of GraphAttributes.