terezka/elm-charts

Remove toBarData and DataTransformers from Plot.Bars

benjamin-bergia opened this issue · 0 comments

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: