Internal.Legends.Config data msg
Use in the LineChart.Config
passed to LineChart.viewCustom
.
chartConfig : LineChart.Config Data msg
chartConfig =
{ ...
, legends = Legends.default
, ...
}
default : Config data msg
Produces legends in the top right corner.
none : Config data msg
Removes the legends.
Where the title is hanging by its respective line.
byEnding : (String -> Svg msg) -> Config data msg
Places the legend by the end of its line.
chartConfig : LineChart.Config Data msg
chartConfig =
{ ...
, legends = Legends.byEnding (Junk.label Colors.black)
, ...
}
See the full example here.
byBeginning : (String -> Svg msg) -> Config data msg
Same as byEnding
, except by the beginning of the line!
Where the titles are gathered in one spot.
grouped : (LineChart.Coordinate.Range -> Basics.Float) -> (LineChart.Coordinate.Range -> Basics.Float) -> Basics.Float -> Basics.Float -> Config data msg
Draws some legends. You desicde where. Arguments:
chartConfig : LineChart.Config Data msg
chartConfig =
{ ...
, legends = Legends.grouped .max .min 0 -60 -- Bottom right corner
, ...
}
Makes this:
See the full example here.
groupedCustom : Basics.Float -> (LineChart.Coordinate.System -> List (Legend msg) -> Svg msg) -> Config data msg
Customize your grouped legends. Arguments:
legends : Legends data msg
legends =
Legends.groupedCustom 30 viewLegends
viewLegends : Coordinate.System -> List (Legends.Legend msg) -> Svg.Svg msg
viewLegends system legends =
Svg.g
[ Junk.transform
[ Junk.move system system.x.min system.y.min
, Junk.offset 20 20
]
]
(List.indexedMap viewLegend legends)
viewLegend : Int -> Legends.Legend msg -> Svg.Svg msg
viewLegend index { sample, label } =
Svg.g
[ Junk.transform [ Junk.offset (toFloat index * 100) 20 ] ]
[ sample, viewLabel label ]
viewLabel : String -> Svg.Svg msg
viewLabel label =
Svg.g
[ Junk.transform [ Junk.offset 40 4 ] ]
[ Junk.label Colors.black label ]
Makes this:
See the full example here.
{ sample : Svg msg
, label : String
}
Stuff that's helpful when you're drawing your legends. A sample of your line as well your line's label.