vandelay vandelay - 1 month ago 13
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

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

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

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

Answer

I think it's as simple as:

(high - low) / 10

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