terezka / elm-charts

Create SVG charts in Elm.
https://www.elm-charts.org
BSD 3-Clause "New" or "Revised" License
711 stars 67 forks source link

Remove toBarData and DataTransformers from Plot.Bars #43

Closed benjamin-bergia closed 7 years ago

benjamin-bergia commented 7 years ago

Hi, I have been playing with your library for one of my side projects. I am far from being an Elm veteran but here are few things that I noticed when working with the Plot.Bars module.

From my understanding, in order to get my data into the Data type, I have to use the toBarData function with a data transformer. This seem to be trivial when using a list of records. During my experimentation, I have been using a Dict type to store my dataset and I have been plagued with type mismatches. So I am wondering if it wouldn't make the whole thing easier to directly expose your internal data type and let users handle the conversion. For example you could define

type alias BarDataSet =
  List BarData

and

type alias BarData =
  { x : Float
  , y : List Float
  }

or even

type alias BarData =
  ( Float
  , List Float 
  )

In an other hand, this is still inconsistent since all the other plots are using a list of Point. So one last solution could be to reuse Point for your bar chart but automagically stack points with the same x value.

In any case, I can live with the current implementation and it won't stop me from using your awesome library. :simple_smile: