-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tick display precision should be configurable #336
Comments
I like this idea, although I'm not a huge fan of using a global variable, as a user may want different precision for different plots or axes. Would it be better to change the Ticker interface to the following: type Ticker interface {
// Ticks returns Ticks in a specified range
Ticks(min, max float64, format func(v float64, prec int) string) []Tick
} and then add a field to Axis.Tick that allows for the specification of a custom format function? (If the custom format function was nil, then the default would be used.) |
Sounds like a plan. I'll give it a shot during the weekend hopefully. |
This also allows the possibility of exporting some of these helpers. |
I created PR #362. |
Commit 2651c0e added a displayPrecision variable in line 18 (2651c0e#diff-d7f174bedb1bfb5e7a82248d40e9b46fR18).
This variable is used to format
float64
ticks. The default value of 4 causes a small-ish number like 20000 to be rendered as2e+04
.The value should be configurable to allow the user to define if he ever wants scientific notation or not.
I can submit a PR that exposes
DefaultDisplayPrecision
as a global variable to plot, by changing theconst
to an exportedvar
but you might have something else in mind. Please let me know how you would like to expose access to that precision without forcing the user to implement his own ticks logic just for the precision.The approach from the wiki example on the comma separated ticks marks based on the default ticks doesn't work because at that point the tick
string
has already been generated using the displayPrecision.The text was updated successfully, but these errors were encountered: