This module contains helpers for cartesian/SVG coordinate translation.
The axis of the plane.
Axis.plane.x.length is the width,
plane.y.length is the height)min and max values is the reach of your plane. (Domain for the y-axis, range
for the x-axis)You may want to produce a plane which fits all your data. For that you need to find the minimum and maximum values withing your data in order to calculate the domain and range.
Helper to extract the minimum value amongst your coordinates.
Helper to extract the maximum value amongst your coordinates.
planeFromPoints : List Point -> Plane
planeFromPoints points =
{ x =
{ marginLower = 10
, marginUpper = 10
, length = 300
, min = minimum .x points
, max = maximum .x points
}
, y =
{ marginLower = 10
, marginUpper = 10
, length = 300
, min = minimum .y points
, max = maximum .y points
}
}Translate a SVG x-coordinate to its cartesian x-coordinate.
Translate a SVG y-coordinate to its cartesian y-coordinate.
For scaling a cartesian value to a SVG value. Note that this will not return a coordinate on the plane, but the scaled value.
Translate a cartesian x-coordinate to its SVG x-coordinate.
Translate a cartesian y-coordinate to its SVG y-coordinate.
For scaling a SVG value to a cartesian value. Note that this will not return a coordinate on the plane, but the scaled value.
A transform translate(x, y) SVG attribute. Beware that using this and
and another transform attribute on the same node, will overwrite the first.
If that's the case, just make one yourself:
myTransformAttribute : Svg.Attribute msg
myTransformAttribute =
transform <|
"translate("
++ String.fromFloat (toSVGX plane x) ++ ","
++ String.fromFloat (toSVGY plane y) ++ ") "
++ "rotateX(" ++ whatever ++ ")"Place at coordinate, but you may add a SVG offset. See place above for important notes.
The properties of your plane.