diff --git a/packages/osd-charts/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-interactions-cursor-update-action-visually-looks-correct-1-snap.png b/packages/osd-charts/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-interactions-cursor-update-action-visually-looks-correct-1-snap.png index e74bf1f00d80..bfd6a82719cd 100644 Binary files a/packages/osd-charts/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-interactions-cursor-update-action-visually-looks-correct-1-snap.png and b/packages/osd-charts/integration/tests/__image_snapshots__/all-test-ts-baseline-visual-tests-for-all-stories-interactions-cursor-update-action-visually-looks-correct-1-snap.png differ diff --git a/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-crosshairs-1-snap.png b/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-crosshairs-1-snap.png index 282f93670f16..f1f07593d474 100644 Binary files a/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-crosshairs-1-snap.png and b/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-crosshairs-1-snap.png differ diff --git a/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-extra-values-in-legend-1-snap.png b/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-extra-values-in-legend-1-snap.png new file mode 100644 index 000000000000..64ae59836d4a Binary files /dev/null and b/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-extra-values-in-legend-1-snap.png differ diff --git a/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-tooltips-1-snap.png b/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-tooltips-1-snap.png index bf61fcbb7765..d2612201ec75 100644 Binary files a/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-tooltips-1-snap.png and b/packages/osd-charts/integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltip-sync-show-synced-tooltips-1-snap.png differ diff --git a/packages/osd-charts/integration/tests/interactions.test.ts b/packages/osd-charts/integration/tests/interactions.test.ts index 7f98e0523f18..caf44747bf12 100644 --- a/packages/osd-charts/integration/tests/interactions.test.ts +++ b/packages/osd-charts/integration/tests/interactions.test.ts @@ -221,16 +221,27 @@ describe('Interactions', () => { it('show synced tooltips', async () => { await common.expectChartWithMouseAtUrlToMatchScreenshot( 'http://localhost:9001/?path=/story/interactions--cursor-update-action&knob-local%20tooltip%20type_Top%20Chart=vertical&knob-local%20tooltip%20type_Bottom%20Chart=vertical&knob-enable%20external%20tooltip_Top%20Chart=true&knob-enable%20external%20tooltip_Bottom%20Chart=true&knob-external%20tooltip%20placement_Top%20Chart=left&knob-external%20tooltip%20placement_Bottom%20Chart=left', - { right: 120, top: 80 }, + { right: 200, top: 80 }, { screenshotSelector: '#story-root', }, ); }); + it('show synced crosshairs', async () => { await common.expectChartWithMouseAtUrlToMatchScreenshot( 'http://localhost:9001/?path=/story/interactions--cursor-update-action&knob-local%20tooltip%20type_Top%20Chart=vertical&knob-local%20tooltip%20type_Bottom%20Chart=vertical&knob-enable%20external%20tooltip_Top%20Chart=true&knob-enable%20external%20tooltip_Bottom%20Chart=false&knob-external%20tooltip%20placement_Top%20Chart=left&knob-external%20tooltip%20placement_Bottom%20Chart=left', - { right: 120, top: 80 }, + { right: 200, top: 80 }, + { + screenshotSelector: '#story-root', + }, + ); + }); + + it('show synced extra values in legend', async () => { + await common.expectChartWithMouseAtUrlToMatchScreenshot( + 'http://localhost:9001/?path=/story/interactions--cursor-update-action&knob-Series type_Top Chart=line&knob-enable external tooltip_Top Chart=true&knob-Series type_Bottom Chart=line&knob-enable external tooltip_Bottom Chart=false', + { right: 200, top: 80 }, { screenshotSelector: '#story-root', }, diff --git a/packages/osd-charts/src/chart_types/xy_chart/state/selectors/get_tooltip_values_highlighted_geoms.ts b/packages/osd-charts/src/chart_types/xy_chart/state/selectors/get_tooltip_values_highlighted_geoms.ts index ba998115b801..0d1807544792 100644 --- a/packages/osd-charts/src/chart_types/xy_chart/state/selectors/get_tooltip_values_highlighted_geoms.ts +++ b/packages/osd-charts/src/chart_types/xy_chart/state/selectors/get_tooltip_values_highlighted_geoms.ts @@ -124,7 +124,7 @@ function getTooltipAndHighlightFromValue( return EMPTY_VALUES; } - if (tooltipType === TooltipType.None) { + if (tooltipType === TooltipType.None && !externalPointerEvent) { return EMPTY_VALUES; } diff --git a/packages/osd-charts/src/components/__snapshots__/chart.test.tsx.snap b/packages/osd-charts/src/components/__snapshots__/chart.test.tsx.snap index b51d62d8c391..12a57953b38a 100644 --- a/packages/osd-charts/src/components/__snapshots__/chart.test.tsx.snap +++ b/packages/osd-charts/src/components/__snapshots__/chart.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Chart should render the legend name test 1`] = `"
"`; +exports[`Chart should render the legend name test 1`] = `"
"`; diff --git a/packages/osd-charts/src/components/tooltip/tooltip.tsx b/packages/osd-charts/src/components/tooltip/tooltip.tsx index 4271b317ca09..3fcc058f8a80 100644 --- a/packages/osd-charts/src/components/tooltip/tooltip.tsx +++ b/packages/osd-charts/src/components/tooltip/tooltip.tsx @@ -203,9 +203,7 @@ const TooltipComponent = ({ boundary: boundary === 'chart' && chartRef.current ? chartRef.current : undefined, }; }, [settings, chartRef, rotation]); - if (!visible) { - return null; - } + return ( = { + bar: BarSeries, + line: LineSeries, + area: AreaSeries, +}; + +const getSeriesKnob = (group?: string) => { + const type = + select( + 'Series type', + { + Bar: 'bar', + Line: 'line', + Area: 'area', + }, + 'bar', + group, + ) ?? 'bar'; + return chartTypes[type] ?? BarSeries; +}; + export const Example = () => { const ref1 = React.createRef(); const ref2 = React.createRef(); @@ -57,6 +80,8 @@ export const Example = () => { const group1 = 'Top Chart'; const group2 = 'Bottom Chart'; + const TopSeries = getSeriesKnob(group1); + const BottomSeries = getSeriesKnob(group2); const topType = getTooltipTypeKnob('local tooltip type', TooltipType.VerticalCursor, group1); const bottomType = getTooltipTypeKnob('local tooltip type', TooltipType.VerticalCursor, group2); const topVisible = boolean('enable external tooltip', true, group1); @@ -68,6 +93,8 @@ export const Example = () => { <> { /> Number(d).toFixed(2)} /> - { { domain={{ min: 5, max: 20 }} /> - { ); }; + Example.story = { parameters: { info: {