Skip to content

How to calculate the top position of the pressed StackedBar #573

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

Open
abrarmohi opened this issue Jun 3, 2025 · 0 comments
Open

How to calculate the top position of the pressed StackedBar #573

abrarmohi opened this issue Jun 3, 2025 · 0 comments

Comments

@abrarmohi
Copy link

Question

How can I calculate the top position of a pressed StackedBar? I have added ChartPressState, which can identify the pressed bar, but calculating the top was somewhat challenging for me. I tried to calculate it in different ways from the ChartPressState, but the position wasn't accurate in all cases.

Image

Background Info/Attempts

Since I noticed 0 on Y axis was top of the canvas, I tried to find the minimum position from the stacked bars, hoping it would be the top-most bar, but it wasn't exactly the case. The goal was to position a Skia Circle at the top of stacked bars for the pressed row.

const [touch1] = touches;

const allY = Object.values(touch1.y)
  .map((entry) => entry.position.value)
  .filter((y) => !isNaN(y));
const minY = Math.min(...allY);
tooltipY1.value = minY;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant