'How do I predict how a chart will trend

I'm working on a JS project where the user draws a graph while the code tries to predict how it will unfold. Does anyone have any ideas how I might be able to accomplish this? Thanks for the help!

picture of my program with what I want the computer to predict



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source