wil moskal
wil moskal

Reputation: 309

Plotly JS line graph has very weird lines

So I have a site where I am doing some data modeling using plotly.js. I am plotting a large number of points (in the thousands). on my backend, I calculate regression equations for the points, and generate coordinates for each x value on the graph. When I plot the equation points in a plotly.js trace, I sometimes get extremely weird results such as enter image description here Which is supposed to be a polynomial curve where I get the points using the equation

    yPoints.push((quad[0] * (m*m)) + (quad[1] * m) + quad[2])

Where quad[0] quad[1] and quad[2] are the coeffecients that I got from determining the regression analysis.

I am not sure why I am getting such weird graph results for certain sets of coordinates. Does anybody have any idea why?

Alternatively does anybody know of any way to plot a function in a plotly.js graph using either plotly or a third party?

let me know if you need any more info. Thanks for the help!

Upvotes: 4

Views: 854

Answers (1)

wil moskal
wil moskal

Reputation: 309

Thanks for all of the comments NVRM. As it turns out it wasn't an SVG issue. It wasn't even a plotly issue. The issue was with my data. I have a database which I query for the data that I used to generate the trendline (the points on the graph). For some reason occasionally the y value of the points that I am generating was NULL. This was causing some oddities with the regression calculations, and there were some outliers generated when the value was NULL.

There is still a few oddities with the graph, but the main one is resolved by removing the values with NULL from the trendline consideration.

The moral of the story is always check your data kids.

Upvotes: 1

Related Questions