gampleman / elm-visualization

A data visualization library for Elm

Home Page:http://package.elm-lang.org/packages/gampleman/elm-visualization/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reverse order of arguments for Scale construction

gampleman opened this issue · comments

Currently, when constructing scales, the arguments are domain and then range. This is somewhat intuitive, but in practice the range is often known statically, whereas the domain is computed from the data.

So currently you can see code like this:

width : Float
width = 800

makeXScale : (Float, Float) -> ContinuousScale
makeXScale domain = 
  Scale.linear domain (0, width)

makeColorScale : (Float, Float) -> SequentialScale Color
makeColorScale domain =
  Scale.sequential domain Scale.viridisInterpolator

whereas if the arguments were reversed, the code would simplify to:

width : Float
width = 800

makeXScale : (Float, Float) -> ContinuousScale
makeXScale =  Scale.linear (0, width)

makeColorScale : (Float, Float) -> SequentialScale Color
makeColorScale = Scale.sequential Scale.viridisInterpolator

Thoughts?