lauber00 / line-charts / LineChart.Axis.Intersection

Where is the intersection?

The intersection is where your two axis lines meet. By default this is at the smallest coordinate possible (the downmost left corner), but it need not be as illustated below.

Ranges explained


type alias Config =
Internal.Axis.Intersection.Config

Use in the LineChart.Config passed to LineChart.viewCustom.

chartConfig : LineChart.Config Data msg
chartConfig =
  { ...
  , intersection = Intersection.default
  , ...
  }

default : Config

Sets the intersection at the minimum on both the range and domain.

intersectionConfig : Intersection.Config
intersectionConfig =
  Intersection.default

See the full example here.

atOrigin : Config

Sets the intersection as close to the origin as your range and domain allows.

intersectionConfig : Intersection.Config
intersectionConfig =
  Intersection.atOrigin

See the full example here.

at : Basics.Float -> Basics.Float -> Config

Sets the intersection to your chosen x and y respectively.

intersectionConfig : Intersection.Config
intersectionConfig =
  Intersection.at 0 3

See the full example here.

custom : (LineChart.Coordinate.Range -> Basics.Float) -> (LineChart.Coordinate.Range -> Basics.Float) -> Config

Sets the intersection to your chosen x and y, given the range and domain respectively.

intersectionConfig : Intersection.Config
intersectionConfig =
  Intersection.custom .min middle

middle : Coordinate.Range -> Float
middle { min, max } =
  min + (max - min) / 2

See the full example here.