Solved Issue in Coding

I am happy I was able to solve my problem in coding that I’ve struggled with for the past few days.

I’m not exactly sure what you want to do here, but I think maybe you want to be able to click and drag the red line horizontally across the graph? Changing the horizontal position of the line can be achieved by setting the x1 and x2 attributes on the <line>. You can add listeners for the mousedown, mousemove, and mouseup events in order to do this. The mousedown listener would check to make sure the mouse is currently over the red line and initiate the movement of the line if it is, the mousemove listener would change the x1 and x2 attributes as the mouse is moved horizontally, and the mouseup listener would stop the moving of the line. How you actually implement this in code I’ll leave up to you.

1 Like