@@ -206,22 +206,22 @@ export class ChartAPI {
206206
207207 // Callbacks used for hover and keyboard navigation, and also exposed to the public API to give the ability
208208 // to highlight and show tooltip for the given point or group manually.
209- public setItemsVisible = ( visibleItemsIds : readonly string [ ] ) => {
210- this . chartExtraLegend . onItemVisibilityChange ( visibleItemsIds ) ;
209+ public setItemsVisible = ( visibleItemsIds : readonly string [ ] , trigger : string = "user" ) => {
210+ this . chartExtraLegend . onItemVisibilityChange ( visibleItemsIds , trigger ) ;
211211 } ;
212- public highlightChartPoint = ( point : Highcharts . Point ) => {
212+ public highlightChartPoint = ( point : Highcharts . Point , trigger : string = "user" ) => {
213213 if ( ! this . isTooltipPinned ) {
214- this . highlightActions ( point ) ;
214+ this . highlightActions ( point , trigger ) ;
215215 }
216216 } ;
217- public highlightChartGroup = ( group : readonly Highcharts . Point [ ] ) => {
217+ public highlightChartGroup = ( group : readonly Highcharts . Point [ ] , trigger : string = "user" ) => {
218218 if ( ! this . isTooltipPinned ) {
219- this . highlightActions ( group as Writeable < Highcharts . Point [ ] > ) ;
219+ this . highlightActions ( group as Writeable < Highcharts . Point [ ] > , trigger ) ;
220220 }
221221 } ;
222- public clearChartHighlight = ( ) => {
222+ public clearChartHighlight = ( trigger : string = "user" ) => {
223223 if ( ! this . isTooltipPinned ) {
224- this . clearHighlightActions ( ) ;
224+ this . clearHighlightActions ( trigger ) ;
225225 }
226226 } ;
227227
@@ -233,12 +233,12 @@ export class ChartAPI {
233233 this . chartExtraNavigation . announceChart ( getChartAccessibleDescription ( this . context . chart ( ) ) ) ;
234234 } ,
235235 onFocusGroup : ( group : Highcharts . Point [ ] ) => {
236- this . highlightActions ( group , true ) ;
236+ this . highlightActions ( group , "user" , true ) ;
237237 this . chartExtraNavigation . announceElement ( getGroupAccessibleDescription ( group ) , false ) ;
238238 } ,
239239 onFocusPoint : ( point : Highcharts . Point ) => {
240240 const labels = this . context . settings . labels ;
241- this . highlightActions ( point , true ) ;
241+ this . highlightActions ( point , "user" , true ) ;
242242 this . chartExtraNavigation . announceElement ( getPointAccessibleDescription ( point , labels ) , false ) ;
243243 } ,
244244 onBlur : ( ) => this . clearChartHighlight ( ) ,
@@ -338,13 +338,13 @@ export class ChartAPI {
338338 // If the previously hovered and now clicked positions match, and the the tooltip wasn't
339339 // dismissed just a moment ago, we make the tooltip pinned in this position.
340340 if ( positionsMatch && ! this . chartExtraTooltip . tooltipLock ) {
341- this . highlightActions ( point ) ;
341+ this . highlightActions ( point , "user" ) ;
342342 this . chartExtraTooltip . pinTooltip ( ) ;
343343 }
344344 // If the tooltip was just dismissed, it means this happened by clicking somewhere in the plot area.
345345 // If the clicked position differs from the one that was pinned - we show tooltip in the new position.
346346 else if ( ! positionsMatch && this . chartExtraTooltip . tooltipLock ) {
347- this . highlightActions ( point , true ) ;
347+ this . highlightActions ( point , "user" , true ) ;
348348 }
349349 } ;
350350
@@ -356,17 +356,21 @@ export class ChartAPI {
356356 // If the previously hovered and now clicked positions match, and the the tooltip wasn't
357357 // dismissed just a moment ago, we make the tooltip pinned in this position.
358358 if ( positionsMatch && ! this . chartExtraTooltip . tooltipLock ) {
359- this . highlightActions ( group ) ;
359+ this . highlightActions ( group , "user" ) ;
360360 this . chartExtraTooltip . pinTooltip ( ) ;
361361 }
362362 // If the tooltip was just dismissed, it means this happened by clicking somewhere in the plot area.
363363 // If the clicked position differs from the one that was pinned - we show tooltip in the new position.
364364 else if ( ! positionsMatch && this . chartExtraTooltip . tooltipLock ) {
365- this . highlightActions ( group , true ) ;
365+ this . highlightActions ( group , "user" , true ) ;
366366 }
367367 } ;
368368
369- private highlightActions ( target : Highcharts . Point | Highcharts . Point [ ] , overrideTooltipLock = false ) {
369+ private highlightActions (
370+ target : Highcharts . Point | Highcharts . Point [ ] ,
371+ trigger : string ,
372+ overrideTooltipLock = false ,
373+ ) {
370374 const point = Array . isArray ( target ) ? null : target ;
371375 const group = Array . isArray ( target ) ? target : this . context . derived . getPointsByX ( target . x ) ;
372376
@@ -388,11 +392,11 @@ export class ChartAPI {
388392 }
389393
390394 // Notify the consumer that a highlight action was made.
391- this . context . handlers . onHighlight ?.( { point, group } ) ;
395+ this . context . handlers . onHighlight ?.( { point, group } , trigger ) ;
392396 }
393397 }
394398
395- private clearHighlightActions = ( ) => {
399+ private clearHighlightActions = ( trigger : string ) => {
396400 if ( ! this . isTooltipPinned ) {
397401 // Update Highcharts elements state.
398402 this . chartExtraHighlight . clearChartItemsHighlight ( ) ;
@@ -402,7 +406,7 @@ export class ChartAPI {
402406 this . chartExtraLegend . onClearHighlight ( ) ;
403407
404408 // Notify the consumer that a clear-highlight action was made.
405- this . context . handlers . onClearHighlight ?.( ) ;
409+ this . context . handlers . onClearHighlight ?.( trigger ) ;
406410 }
407411 } ;
408412
0 commit comments