Skip to content

Improved tooltip callback parameters #7563

Description

@benmccann

I have a timeseries scale and am trying to use the formatted x value as the tooltip title. Today I'm just returning the input data as given:

title: function(items, data) {
	const item = items[0];
	const value = data.datasets[item.datasetIndex].data[item.index];
	return value.x;
}

There's no way to access the parsed data here, which is really what I want. Right now I'd have to parse it again (duplicating the scale's parsing code in my own code) before formatting it in my desired format. One idea would be to replace items and data (which are the parameters for most or all of the callbacks) with a context object like we use for scriptable options.

I also noticed that the tooltip callbacks are nested in the options object under callbacks, which seems inconsistent to me. We have lots of options which are able to take functions as values and haven't nested them under callbacks elsewhere, so this is something else we might consider changing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions