-
Notifications
You must be signed in to change notification settings - Fork 458
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
Add labelIndex to context so functions can know which label for a given datapoint is referenced #265
Comments
Just to add some further context since I've since discovered the way it was intended. Looking through the past issues on similar themes it stems from a critical hole in the documentation. It isn't clear in the documentation that you can specify a custom formatter (in fact you must for it to be useful) per label within the My perspective coming in was that I could only define the one formatter, yet had no mechanism to determine which label the formatter was being called for. So while I have found 'the way' now, i can still see some use cases where having the label index in the context for use by a common formatter may be useful. I see no harm in adding it, and it allows for multiple ways to accomplish a given goal depending on the users requirements. I'll leave this open with the intent as a feature request rather than a bug as I still do see some benefit in having the additional meta-data within |
Currently if you have multiple labels for a given data point [say a "label" and "value"] there is no easy way for code to know how to respond. ie a formatter doesn't know if it is to return a label or a value, a display function doesn't know if it should show or hide. etc. At least not without adding adding a fair amount of fragile external code to try and track which label it is by assuming call order. Externally adding a property to
context
suffers the same problem, as you still need to know which label the context applies to when you first set the value. As it stands the formatter or display function [in my test case on a doughnut chart] are called twice, once for each label, with the exact same context content, with no discernible way to distinguish which label is being referenced without externally tracking the call order.Luckily the internal solution is easy... just one line in the definition of
context
This is the simplest solution, which works, but certainly more elegant options exist as well.
The text was updated successfully, but these errors were encountered: