heatmap.js
heatmap.js copied to clipboard
How not to change 'max' when adding point with addData?
I set 'max' and initial data with heatmap.setData({ max: 6, data: heatmapData });
but when I add datapoints with heatmap.addData(..)
the 'max' value automatically changes, so I didn't found any better then call heatmap.setDataMax(6);
after each addData()
.
Is it possible set 'max' once for all and not change it with addData()
?
I've just come across this same issue. Did you find a better solution?
When I call addData
both my min and max are getting set to whatever the value of the point I added was which breaks the whole thing. To counter this I call setDataMin
and setDataMax
after each addData
call but in some cases this causes the heatmap not even to be painted at all for some reason.
The other alternative I'm thinking is to just call setData
every time but this seems silly when I'm adding data frequently (many times a second).
I just noticed I was passing x
and y
values that were non-integers. Once I rounded these before calling addData
the problem seems to have gone away. addData
no longer resets the the min
and max
values. Given that the value
of a data point has to be an integer I'm assuming maybe the coordinates have to be as well.
@axwalker Your solution - rounding to integers didn't seem to work for me. Solution I came up with (ugly but force fixes the issue) was to simply overwrite the setDataMax
function.
heatmapInstance._store.setDataMax = function(max) {
return this;
}