0

I need some help.

I am developing a project in React JS. I am using react-chartjs-2 for displaying charts. I have to add a range slider for the chart to control values on x-axis and two vertical lines. The position of one vertical line on the chart is controlled by the range slider. I somehow managed to solve this problem. Another line has to be displayed at a specific point(calculated using an equation). I am able to draw this line as well. Actually, I am drawing lines on the chart's canvas.

But the problem is that when I get a new point using the equation, I have to remove the vertical line at the previous point. How can I do that? I have tried all the solutions on StackOverflow, but couldn't solve this problem.

Farhan Ali
  • 116
  • 5

1 Answers1

0

As described in this SO question you cannot clear a single element, you have to clear the entire canvas and redraw everything.

LeeLenalee
  • 27,463
  • 6
  • 45
  • 69