Update Histogram Bins
by ramnathv
HTML
<script src="//rawgit.com/ramnathv/7d92a0c9bf3257748fa4/raw/4dcba4f9df9f136036c3c7ad7a2e3ed1eb72a353/data6.js"></script>
CoffeeScript
x = [{"x": 0, "y" : 13},{"x": 10, "y" : 19},{"x": 20, "y" : 3},{"x": 30, "y" : 7},{"x": 40, "y" : 5},{"x": 50, "y" : 7},{"x": 80, "y" : 1},{"x": 90, "y" : 1}]
D = DATA2()
updateBins = (D) ->
fillBins = (column) ->
x = column.value
step = column.binsize
n = x.length
x.forEach (d, i) ->
if (i < n - 1)
if (x[i + 1].x - x[i].x) != step
x.splice(i + 1, 0, {x: x[i].x + step, y: 0})
column
D.forEach (d_) ->
if (d_.binsize)
fillBins(d_)
else
d_
updateBins(D)
console.log JSON.stringify(D)
###
step = 10
x.forEach (d, i) ->
if (x[i + 1].x - x[i].x) != step
x.splice(i + 1, 0, {x: x[i].x + step, y: 0})
console.log JSON.stringify(x)
###