Skip to content

Utilizing Plot Events of G2 Plot in React Component #354

Answered by kagawagao
jagijan asked this question in Q&A
Discussion options

You must be logged in to vote

you can use chartRef to access chart plot instance, then follow g2plot events api to bind event

  const lineChartRef = useRef<Line>();
  useEffect(() => {
    if (lineChartRef.current) {
      const plot = lineChartRef.current;
      plot.on("line:click", (e) => {
        console.log(e);
      });
    }
  }, []);

demo

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kagawagao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants