vandelay vandelay - 10 months ago 69
Javascript Question

Find points with range between two numbers

I'm trying to make a stock chart, and were looking for a way to properly split the price on the x-axis and the date (in milliseconds) on the y-axis.

if I for example have

dates, I can't show them all. But would like to show

so if I have two dates
Is there some function in javascript that can find
evenly spread numbers between them?

The same goes for price, but I guess that's pretty much the same.

Answer Source

I think it's as simple as:

(high - low) / 10

That gets your step size. Then, loop through adding that step size each iteration.