OWScatterplotGraph: Use get_color_labels to return number formatter #3847
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #3746 - displaying of datetime variables in visualization legends, as well as, probably, weird number of decimals for other numeric attributes.
Description of changes
Labels for color legend are created by palette, which is not aware of attributes. Palette is called by
OWScatterplotGraph
, which also doesn't know about attributes. On the other hand, the widget, which provides labels for discrete attributes (viaget_color_labels
), doesn't know how the graph will discretize continuous values, hence it can't provide a list.A reasonable solution is that
get_color_labels
, which currently returnsNone
for continuous variables, returns a formatter, that is, function that takes a number and returns a string. For most cases, this will be variablesstr_val
. If it returnsNone
, the widget uses the same formatter as it did before (a certain number of decimals, computed based on God knows what),Includes