terezka/elm-plot/4.0.0

NOTE: this package is not compatible with Elm 0.19.1

Plot.Axis

Attributes for altering the view of your axis.

Definition

type alias Attribute msg =
Config msg -> Config msg

Attributes

classes : List String -> Attribute msg

Adds classes to the container holding your axis.

myXAxis : Plot.Element msg
myXAxis =
    Plot.xAxis
        [ Axis.view
            [ Axis.classes [ "axis--x" ] ]
        ]
line : List (Attribute msg) -> Attribute msg

Adds styles to the axis line.

myXAxis : Plot.Element msg
myXAxis =
    Plot.xAxis
        [ Axis.view
            [ Axis.line [ Line.stroke "blue" ] ]
        ]
positionLowest : Attribute msg

Position this axis to the lowest value on the opposite axis. E.g. if this attribute is added on an y-axis, it will be positioned to the left.

myXAxis : Plot.Element msg
myXAxis =
    Plot.xAxis
        [ Axis.view
            [ Axis.positionLowest ]
        ]
positionHighest : Attribute msg

Position this axis to the highest value on the opposite axis. E.g. if this attribute is added on an y-axis, it will be positioned to the right.

myXAxis : Plot.Element msg
myXAxis =
    Plot.xAxis
        [ Axis.view
            [ Axis.positionHighest ]
        ]
cleanCrossings : Attribute msg

Remove tick and value where the axis crosses the opposite axis.

myXAxis : Plot.Element msg
myXAxis =
    Plot.xAxis
        [ Axis.view [ Axis.cleanCrossings ] ]
anchorInside : Attribute msg

Anchor the ticks/labels on the inside of the plot. By default they are anchored on the outside.

myXAxis : Plot.Element msg
myXAxis =
    Plot.xAxis
        [ Axis.view
            [ Axis.anchorInside ]
        ]

Ticks and labels

tick : List (Attribute LabelInfo msg) -> Attribute msg

By providing this attribute with a list of tick attributes, you may alter the values and ticks displayed as your axis' ticks.

myYAxis : Plot.Element msg
myYAxis =
    Plot.yAxis
        [ Axis.tick
            [ Tick.view [ Tick.length 3 ] ]
        , Axis.tickValues [ 2, 4, 6 ]
        ]
tickValues : List Float -> Attribute msg

Specify at what values will be added a tick.

myXAxis : Plot.Element msg
myXAxis =
    Plot.xAxis
        [ Axis.tickValues [ 0, 1, 2, 4, 8 ] ]

Note: If you add another attribute msgltering the values like tickDelta after this attribute, then this attribute will have no effect.

tickDelta : Float -> Attribute msg

Specify what values will be added a tick by specifying the space between each tick.

myXAxis : Plot.Element msg
myXAxis =
    Plot.xAxis
        [ Axis.tickDelta 4 ]

Note: If you add another attribute msgltering the values like tickValues after this attribute, then this attribute will have no effect.

type alias LabelInfo =
{ value : Float
, index : Int
}
label : List (Attribute LabelInfo msg) -> Attribute msg

By providing this attribute with a list of label attributes, you may alter the values and ticks displayed as your axis' labels.

myYAxis : Plot.Element msg
myYAxis =
    Plot.yAxis
        [ Axis.label
            [ Label.view
                [ Label.displace (10, 0)
                , Label.stroke "blue"
                ]
            , Label.format (.value >> toString)
            ]
        ]
labelValues : List Value -> Attribute msg

Specify the values which you want a label for. If not specified, it will mirror the tick values.

myYAxis : Plot.Element msg
myYAxis =
    Plot.yAxis
        [ Axis.labelValues [ 0, 5, 10, 11 ] ]