Skip to content

Tooltip SyncMethod not working #3529

Answered by Yilun-Sun
LucieSumToZero asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @LucieSumToZero ! Thanks for the example!
I think you could use syncMethod to make it synchronized (do a little hack).

2023-04-18.18.52.16.mov

It will calculate the nearby tick in data set 2 using the actived value in data set 1.

Core Code

const closest = (arr: number[], n: number) =>
  arr.sort((a, b) => Math.abs(a - n) - Math.abs(b - n))[0];


export default function App() {
  const syncMethodFunction = (_tooltipTicks: [], data: any) => {
    const closestValue = closest(
      data02.map((data) => data.x),
      Number(data.activeLabel)
    );

    return data02.findIndex((data) => data.x === closestValue);
  };

  return (
    <div>
      <h4>A demo of synchronized AreaCharts

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Yilun-Sun
Comment options

Answer selected by LucieSumToZero
@LucieSumToZero
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants