If you're confused as to what "axis range" and "data range" means,
check out Axis.Range
for an explanation!
Internal.Axis.Config data msg
Use in the LineChart.Config
passed to LineChart.viewCustom
.
chartConfig : LineChart.Config data msg
chartConfig =
{ ...
, x = Axis.default 650 "Age (years)" .age
, y = Axis.default 400 "Weight (kg)" .weight
, ...
}
default : Basics.Int -> String -> (data -> Basics.Float) -> Config data msg
Draws a line the full length of your data range and adds a little space on both sides of that line. Also adds some nice ticks to it.
Pass the length of your axis in pixels, the title and it's variable.
xAxisConfig : Axis.Config Data msg
xAxisConfig =
Axis.default 650 "Age (years)" .age
See the full example here.
full : Basics.Int -> String -> (data -> Basics.Float) -> Config data msg
Draws a line the full length of your axis range and adds some nice ticks to it.
Pass the length of your axis in pixels, the title and it's variable.
xAxisConfig : Axis.Config Data msg
xAxisConfig =
Axis.full 650 "Age (years)" .age
See the full example here.
time : Time.Zone -> Basics.Int -> String -> (data -> Basics.Float) -> Config data msg
Draws a line the full length of your data range and adds some nice datetime ticks to it.
Pass the length of your axis in pixels, the title and it's variable.
xAxisConfig : Axis.Config Data msg
xAxisConfig =
Axis.time 650 "Date" .date
See the full example here.
none : Basics.Int -> (data -> Basics.Float) -> Config data msg
Doesn't draw the axis at all.
Pass the length of your axis in pixels and it's variable.
xAxisConfig : Axis.Config Data msg
xAxisConfig =
Axis.none 650 .age
See the full example here.
picky : Basics.Int -> String -> (data -> Basics.Float) -> List Basics.Float -> Config data msg
Draws the full length of your axis range and adds some ticks at the positions specified in the last argument.
Pass the length of your axis in pixels, the title, it's variable and the numbers where you'd like ticks to show up.
xAxisConfig : Axis.Config Data msg
xAxisConfig =
Axis.picky 650 "Age (years)" .age [ 4, 25, 46 ]
See the full example here.
Note: This is of course not the only way for you to decide exactly where the
ticks should go on the axis! If you need to customize ticks further, check out
the ticks
property in Axis.custom
.
custom : Properties data msg -> Config data msg
Properties:
LineChart.Axis.Title
for more information and examples.LineChart.Axis.Range
for more information and examples.LineChart.Axis.Line
for more information and examples.ticks: Customizes your ticks.
See LineChart.Axis.Ticks
for more information and examples.
xAxisConfig : Axis.Config Data msg xAxisConfig = Axis.custom { title = Title.default "Year" , variable = Just << .date , pixels = 700 , range = Range.padded 20 20 , axisLine = AxisLine.full Colors.black , ticks = Ticks.time 5 }
See the full example here.