-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
feature-requestNew feature or requestNew feature or request
Description
Summary
Allow to provide an element instance from the custom tooltip callback in addition to just an HTML string. This would make it a lot easier to integrate with other libraries and frontend stacks.
API Changes
Really just this:
- tooltipEl.innerHTML = fn({
+ const customTooltip = fn({
ctx: this.ctx,
series: w.globals.series,
seriesIndex: i,
dataPointIndex: j,
y1,
y2,
w,
})
+
+ if (typeof customTooltip === 'string') {
+ tooltipEl.innerHTML = customTooltip
+ } else {
+ tooltipEl.appendChild(customTooltip)
+ }src/modules/tooltip/Labels.js, Lines 527–535
Intended Use Case
This allows the custom tooltip callback to not only return an HTML string, but also an HTML element instance, which solves a slew of issues and user questions, and allows more advanced integration, such as using a prop in React, or a slot in a Vue component, to render a tooltip.
The API change doesn't introduce any backwards incompatibilities.
Metadata
Metadata
Assignees
Labels
feature-requestNew feature or requestNew feature or request