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

feat(react-charts-preview): Migrate VSBC to V9 #33909

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add tabster
  • Loading branch information
Anush2303 committed Feb 28, 2025
commit 72e3c948720f1a3852e5933cefb39e55d2cfd646
Original file line number Diff line number Diff line change
@@ -238,7 +238,21 @@ export const VerticalStackedBarChart: React.FunctionComponent<VerticalStackedBar
setColor(lineData.color);
}

function onStackHoverFocus(stack: VerticalStackedChartProps, mouseEvent: React.MouseEvent<SVGElement>): void {
function onStackHoverFocus(
stack: VerticalStackedChartProps,
mouseEvent: React.MouseEvent<SVGElement> | SVGGElement,
): void {
let clientX = 0;
let clientY = 0;
if ('clientX' in mouseEvent) {
clientX = mouseEvent.clientX;
clientY = mouseEvent.clientY;
} else {
// Handle case where mouseEvent is an SVGGElement
const boundingRect = mouseEvent.getBoundingClientRect();
clientX = boundingRect.left + boundingRect.width / 2;
clientY = boundingRect.top + boundingRect.height / 2;
}
if (!_noLegendHighlighted()) {
stack = {
...stack,
@@ -254,7 +268,7 @@ export const VerticalStackedBarChart: React.FunctionComponent<VerticalStackedBar
item.shouldDrawBorderBottom = true;
});
}
updatePosition(mouseEvent.clientX, mouseEvent.clientY);
updatePosition(clientX, clientY);
setPopoverOpen(stack.chartData.length > 0 || (stack.lineData?.length ?? 0) > 0);
setYValueHover(
isLinesPresent
@@ -669,14 +683,25 @@ export const VerticalStackedBarChart: React.FunctionComponent<VerticalStackedBar
xAxisPoint: string,
point: VSChartDataPoint,
color: string,
mouseEvent: React.MouseEvent<SVGElement>,
mouseEvent: React.MouseEvent<SVGElement> | SVGGElement,
) {
let clientX = 0,
clientY = 0;
if ('clientX' in mouseEvent) {
clientX = mouseEvent.clientX;
clientY = mouseEvent.clientY;
} else {
// Handle case where mouseEvent is an SVGGElement
const boundingRect = mouseEvent.getBoundingClientRect();
clientX = boundingRect.left + boundingRect.width / 2;
clientY = boundingRect.top + boundingRect.height / 2;
}
if (_calloutAnchorPoint?.chartDataPoint !== point || _calloutAnchorPoint?.xAxisDataPoint !== xAxisPoint) {
_calloutAnchorPoint = {
chartDataPoint: point,
xAxisDataPoint: xAxisPoint,
};
updatePosition(mouseEvent.clientX, mouseEvent.clientY);
updatePosition(clientX, clientY);
setPopoverOpen(_noLegendHighlighted() || _isLegendHighlighted(point.legend));
setCalloutLegend(point.legend);
setDataForHoverCard(point.data);
@@ -1003,6 +1028,7 @@ export const VerticalStackedBarChart: React.FunctionComponent<VerticalStackedBar
ref={e => (ref.refElement = e)}
{...rectFocusProps}
transform={`translate(${xScaleBandwidthTranslate}, 0)`}
tabIndex={point.legend !== '' ? 0 : undefined}
/>
</React.Fragment>
);
Loading
Oops, something went wrong.