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.
I have a timeseries scale and am trying to use the formatted
xvalue as the tooltip title. Today I'm just returning the input data as given: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
itemsanddata(which are the parameters for most or all of the callbacks) with acontextobject 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 undercallbackselsewhere, so this is something else we might consider changing.