Skip to content
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

Hierarchical tooltip configuration definitions #3003

Closed
tiagoroldao opened this issue Jul 20, 2016 · 1 comment · Fixed by #8640
Closed

Hierarchical tooltip configuration definitions #3003

tiagoroldao opened this issue Jul 20, 2016 · 1 comment · Fixed by #8640

Comments

@tiagoroldao
Copy link
Contributor

tiagoroldao commented Jul 20, 2016

As tooltips are triggered on Elements, a hierarchical callback definition could be made - callbacks are called if defined in (in order of preference):

  • the dataset
  • the axis
  • the chart
  • the chart globals

The reasoning behind this feature is that while creating a complex chart with different needs for label formatting, I found myself doing this a lot:

chartOptions = {
    [...]
    tooltips: {
        callbacks: {
            label: function (tooltip, data) {
                // real implementation accounts for nonexistent object properties
                var datasetCallback = data.datasets[tooltip.datasetIndex].tooltips.callbacks.label;

                if (typeof datasetCallback === 'function') {
                    return datasetCallback(tooltip, data);
                }

                return tooltip.yLabel;
            }
        }
    }
}
@tiagoroldao tiagoroldao changed the title Greater tooltip configuration flexibility Hierarchical tooltip configuration definitions Jul 20, 2016
@etimberg
Copy link
Member

This seems like an interesting idea. Thoughts @tannerlinsley @derekperkins @zachpanz88 @simonbrunel ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants