timbod7 / haskell-chart

A 2D charting library for haskell
430 stars 85 forks source link

Proposal: allow also absolute spot scaling for AreaSpots? #212

Open mpilgrem opened 5 years ago

mpilgrem commented 5 years ago

Currently, AreaSpots allows the relative scaling of the size of spots through:

 _area_spots_max_radius :: Double  -- the largest size of spot

I found myself needing to scale the size of spots in absolute terms (so that the size of spots in different plots was consistent). I have done that in a fork, with a change to the API. Would that be of interest? If yes, I'll make a pull request.

I introduce:

_area_spots_scale :: [z] -> z -> Double -- a function that maps a z value to the radius of the spot

and two functions:

areaSpotsScaleMaxRadius :: PlotValue z
                        => Double  -- the largest radius of spot
                        -> [z] -> z -> Double

(which replicates what _area_spots_max_radius provides) and:

areaSpotsScale :: PlotValue z
               => Double  -- the scaling factor from toValue z to the radius of spot
               -> [z] -> z -> Double

(where the first argument is an absolute scaling factor).

The default of 'areaSpotsScaleMaxRadius 20.0' is retained.