Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Visualize] Coloring tooltips in Pie are not properly positioned #123042

Closed
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* Side Public License, v 1.
*/

import React, { useCallback } from 'react';
import React from 'react';
import Color from 'color';
import { LegendColorPicker, Position } from '@elastic/charts';
import { PopoverAnchorPosition, EuiPopover, EuiOutsideClickDetector } from '@elastic/eui';
import { PopoverAnchorPosition, EuiWrappingPopover } from '@elastic/eui';
import type { DatatableRow } from '../../../../expressions/public';
import type { PersistedState } from '../../../../visualizations/public';
import { ColorPicker } from '../../../../charts/public';
Expand Down Expand Up @@ -81,38 +81,32 @@ export const getColorPicker =
keyDownEventOn = true;
};

const handleOutsideClick = useCallback(() => {
onClose?.();
}, [onClose]);

if (!distinctColors) {
const enablePicker =
isOnInnerLayer(bucketColumns[0], data, seriesName) || !bucketColumns[0].id;
if (!enablePicker) return null;
}
const hexColor = new Color(color).hex();
return (
<EuiOutsideClickDetector onOutsideClick={handleOutsideClick}>
<EuiPopover
isOpen
ownFocus
display="block"
button={anchor}
anchorPosition={getAnchorPosition(legendPosition)}
closePopover={onClose}
panelPaddingSize="s"
>
<ColorPicker
color={palette === 'kibana_palette' ? hexColor : hexColor.toLowerCase()}
onChange={handleChange}
label={seriesName}
maxDepth={bucketColumns.length}
layerIndex={getLayerIndex(seriesName, data, bucketColumns)}
useLegacyColors={palette === 'kibana_palette'}
colorIsOverwritten={colorIsOverwritten}
onKeyDown={onKeyDown}
/>
</EuiPopover>
</EuiOutsideClickDetector>
<EuiWrappingPopover
isOpen
ownFocus
display="block"
button={anchor}
anchorPosition={getAnchorPosition(legendPosition)}
closePopover={onClose}
panelPaddingSize="s"
>
<ColorPicker
color={palette === 'kibana_palette' ? hexColor : hexColor.toLowerCase()}
onChange={handleChange}
label={seriesName}
maxDepth={bucketColumns.length}
layerIndex={getLayerIndex(seriesName, data, bucketColumns)}
useLegacyColors={palette === 'kibana_palette'}
colorIsOverwritten={colorIsOverwritten}
onKeyDown={onKeyDown}
/>
</EuiWrappingPopover>
);
};