* Fix for getLabelAndValue on null controller
I encountered #11315 under the following circumstances:
1. Position the cursor over the chart area, such that it causes a
tooltip to be shown.
2. Move the cursor out of the chart area, such that the tooltip remains
visible.
3. Cause the chart contents to be changed, such that the dataset
referenced by the active tooltip element is no longer valid.
4. Move the mouse again. This triggers an `inChartArea = false` event,
so it reuses the previous, now invalid, active elements.
This fixes#11315 under the circumstances for which I've reproduced it,
but there may be others.
* Further fixes for elements added / changed
This possibly fixes#11365.
* Improve positioner types; allow overriding xAlign and yAlign
* More type improvements; pass in Chart as third parameter
* Expose chart as part of TooltipModel
I initially passed the Chart element as the third parameter to the positioner; however, Scale and LegendElement elements expose `this.chart`, and sample code for positioners used `this._chart`, so documenting the chart member and giving it a public name seems to make more sense.
* Update documentation
* Fix documentation
* Fix issues from code review
* Fix cleaning up metasets
I believe it's a mistake to only delete the metaset if it has a valid controller; see f191f2f5 for where this behavior was introduced.
This is a minimal fix for #9653; as discussed there, it may also be worth updating `updateHoverStyle`.
As of #7030, `this._metasets` should always be defined, so checking whether it's undefined is no longer necessary.
* Add a test covering metaset behavior
* Add a regression test for #9653; fix `toHaveSize` usage
* Fix test failure
* Update plugin to use it's own tooltip context
* Scriptable tooltip option types
* Tests
* Update types to use UnionToIntersection
* Update TooltipItem to use UnionToIntersection
* Create standardized text render method
* Document renderText options and enable configurable decoration width
* Add tests for font rendering
* Split color definition to it's own file
* renderText supports setting styles
* Mock context needs to track textBaseline
* renderText can set textAlign and textBaseline
* renderText does not mutate the context + translate/rotate
* Explicitly set the text decoration style
* Move useStroke logic into renderText
* Cartesian scale: Update computeLabelItems to avoid duplicate allocations
* Allow the tooltip to get closer to the canvas edge
Closer to the top & bottom by considering (height/2) instead of height.
* Update missing options in TS types
* Remove unneeded brackets
Provide APIs to set active (hovered) and tooltip elements.
Chart.setActiveElements will set the hovered items.
Chart.tooltip.setActiveElements will set the tooltip items.