-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(highlighter): hide it when tooltip type is None (#482)
If the tooltip type is hidden (TooltipType.None) then the tooltip should not be shown. This add the check on the selector and includes also a smoke test. fix #478, fix #479
- Loading branch information
Showing
9 changed files
with
311 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/chart_types/xy_chart/state/chart_state.tooltip.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { GlobalChartState, chartStoreReducer } from '../../../state/chart_state'; | ||
import { createStore, Store } from 'redux'; | ||
import { upsertSpec, specParsed } from '../../../state/actions/specs'; | ||
import { MockSeriesSpec, MockGlobalSpec } from '../../../mocks/specs'; | ||
import { updateParentDimensions } from '../../../state/actions/chart_settings'; | ||
import { getTooltipValuesAndGeometriesSelector } from './selectors/get_tooltip_values_highlighted_geoms'; | ||
import { onPointerMove } from '../../../state/actions/mouse'; | ||
import { TooltipType } from '../utils/interactions'; | ||
|
||
describe('XYChart - State tooltips', () => { | ||
let store: Store<GlobalChartState>; | ||
beforeEach(() => { | ||
const storeReducer = chartStoreReducer('chartId'); | ||
store = createStore(storeReducer); | ||
store.dispatch(upsertSpec(MockSeriesSpec.bar({ data: [{ x: 1, y: 10 }, { x: 2, y: 5 }] }))); | ||
store.dispatch(upsertSpec(MockGlobalSpec.settings())); | ||
store.dispatch(specParsed()); | ||
store.dispatch(updateParentDimensions({ width: 100, height: 100, top: 0, left: 0 })); | ||
}); | ||
|
||
describe('should compute tooltip values depending on tooltip type', () => { | ||
it.each<[TooltipType, number, number]>([ | ||
[TooltipType.None, 0, 0], | ||
[TooltipType.Follow, 1, 2], | ||
[TooltipType.VerticalCursor, 1, 2], | ||
[TooltipType.Crosshairs, 1, 2], | ||
])('tooltip type %s', (tooltipType, expectedHgeomsLength, expectedTooltipValuesLength) => { | ||
store.dispatch(onPointerMove({ x: 25, y: 50 }, 0)); | ||
store.dispatch( | ||
upsertSpec( | ||
MockGlobalSpec.settings({ | ||
tooltip: { | ||
type: tooltipType, | ||
}, | ||
}), | ||
), | ||
); | ||
store.dispatch(specParsed()); | ||
const state = store.getState(); | ||
const tooltipValues = getTooltipValuesAndGeometriesSelector(state); | ||
expect(tooltipValues.tooltipValues).toHaveLength(expectedTooltipValuesLength); | ||
expect(tooltipValues.highlightedGeometries).toHaveLength(expectedHgeomsLength); | ||
}); | ||
}); | ||
}); |
17 changes: 3 additions & 14 deletions
17
src/chart_types/xy_chart/state/selectors/get_specs.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.