Closed PragTob closed 8 years ago
Ah yes I think that would be nice to add Percent
. But now you make me think about naming, and about how Count
and Duration
aren't actually units, but really just collections of functions for converting/scaling/formatting values that represent counts or durations. That makes me want to do something like
conversion
├── count.ex
├── duration.ex
├── format.ex
├── percent.ex
└── scale.ex
This violates the parity between directories/modules that you were after in #37, but it seems a little clearer, since Percent
makes sense as a conversion, but not as a unit. Unit
would get split out into Scale
and Format
behaviours. Count
and Duration
would adopt Scale
and Format
behaviours, while Percent
would adopt only Format
.
What do you think?
Love it :+1:
@PragTob reorganized "Conversion" code as discussed above. Should make Percent
easy. Will break plotlyjs formatter, since you were using the Common
module. But now you can just use those functions on Scale
/Format
.
@wasnotrice will upgrade plotly_js with pleasure :)
In the upcoming plootly_js/HTML formatter I already happily reuse our newly created unit formatting methods (well I don't scale to microseconds because Erlang doesn't like that cause it apparently can't UTF8 but wel'll see about that) and then noticed that it'd be great to have same formatting for percent units (e.g. the ratio of the standard deviation) as in the console formatter.
Right now it's a private method on the console formatter, we could make it public, but that feels wrong. My idea was to create a
Percent
orRatio
or something unit that then encapsulates the formatting of this unit much likeCount
andDuration
do. The weird thing would be, that I don't see any scaling happening there. We'd just always scale to percent (for now).I still think it sort of fits into the concept of a unit... @wasnotrice what do you think? Would love to get your input here!