This is a mischaracterization what curve-fitting algorithms do. You generally have to pick the function you want to fit, and then it's parameters are varied to minimize some comparison function. This means that this function would need to take the data, a chosen function, and a comparison function to minimize.
Also, this is a pure JavaScript project, and the OP wants to do something with HTML/CSS/etc.