This module contains higher-level SVG plotting elements.
An dot with a view which is wrapped in a g element and positioned with a transform.
A dot without visual representation.
An dot with a view where you control how it's positioned.
Series with no interpolation.
Series with linear interpolation.
Area series with linear interpolation.
Series with monotone interpolation.
Area series with monotone interpolation.
These elements render a line series if no fill attribute is added!
areaSeries : Svg msg
areaSeries =
monotone plane [ fill "pink" ] dots
lineSeries : Svg msg
lineSeries =
monotone plane [] dotsYou can draw a bar chart like this:
group : List Float -> List (Bar msg)
group =
List.map (Bar [ stroke "pink", fill "lightpink" ])
groups : Groups msg
groups =
{ groups = List.map group [ [ 2, 3, 1 ], [ 5, 1, 4 ], [ 1, 5, 3 ] ]
, width = 0.8
}
main : Svg msg
main =
svg
[ width (String.fromFloat plane.x.length)
, height (String.fromFloat plane.y.length)
]
[ grouped plane groups ]Note on width: The width takes catersian units, however, should you have
a width in SVG units, you can use Svg.Coordinates.scaleCartesian to
translate it into cartesian units.
The bars are the class frequencies and the interval is the class interval's upper limit minus lower limit. Right now, you can only have equal class intervals, but I might add unequal support later!
frequencies : List Float
frequencies =
[ 1, 2, 3, 6, 8, 9, 6, 4, 2, 1 ]
testScores : Histogram msg
testScores =
{ bars = List.map (Bar [ stroke blueStroke, fill blueFill ]) frequencies
, interval = 1
}
main : Svg msg
main =
svg
[ width (String.fromFloat plane.x.length)
, height (String.fromFloat plane.y.length)
]
[ histogram plane testScores ]Renders a line.
myLine : Svg msg
myLine =
horizontal plane [ stroke "pink" ] x0 y0 x1 y1Renders a horizontal line with the full length of the range.
myXAxisOrGridLine : Svg msg
myXAxisOrGridLine =
fullHorizontal plane [] yPositionRenders a vertical line with the full length of the domain.
myYAxisOrGridLine : Svg msg
myYAxisOrGridLine =
fullVertical plane [] xPositionRenders a horizontal line.
myLine : Svg msg
myLine =
horizontal plane [ stroke "pink" ] y x0 x1Renders a vertical line.
myLine : Svg msg
myLine =
vertical plane [ stroke "pink" ] x y0 y1ProTip: Passing a negative value as the height/width of a tick renders it mirrored on the other side of the axis!
Renders a single tick for the horizontal axis.
Renders ticks for the horizontal axis.
horizontalTicks : Svg msg
horizontalTicks =
xTicks plane height [ stroke "pink" ] axisYCoordinate tickPositionsRenders a single tick for the vertical axis.
Renders ticks for the vertical axis.
verticalTicks : Svg msg
verticalTicks =
yTicks plane width [ stroke "pink" ] axisXCoordinate tickPositionsRenders a label for the horizontal axis.
horizontalLabel : Svg msg
horizontalLabel =
xLabel "blue" String.fromFloat plane y xRenders labels for the horizontal axis.
horizontalLabels : Svg msg
horizontalLabels =
xLabels plane (xLabel "blue" String.fromFloat) axisYCoordinate tickPositionsRenders a label for the vertical axis.
verticalLabel : Svg msg
verticalLabel =
yLabel "blue" String.fromFloat plane x yRenders labels for the vertical axis.
verticalLabels : Svg msg
verticalLabels =
yLabels plane (yLabel "blue" String.fromFloat) axisXCoordinate tickPositions