heatmap.js: Cannot assign to read only property 'data' of object
When using heatmap.js on certain browsers, this error Cannot assign to read only property 'data' of object shows up.

I’m able to reproduce on chromium that is packaged with electron version 1.3.3.
This seems to happen because the data property of ImageData object is being replaced directly in this part of the code. https://github.com/pa7/heatmap.js/blob/master/src/renderer/canvas2d.js#L280
data property seems to be read only on certain browser versions. To fix it, we need to delete this line because imgData and img.data points to the same reference. Any modifications you do to imgData is already reflected to img.data. I’ll put up a PR soon.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 9
- Comments: 15
Commits related to this issue
- removed img.data replacement due to the following issue: https://github.com/pa7/heatmap.js/issues/219 — committed to ionata/heatmap.js by patskot 5 years ago
- Use heatmap.js fork due to https://github.com/pa7/heatmap.js/issues/219 — committed to dalen/killboard by dalen a year ago
- Use heatmap.js fork due to pa7/heatmap.js#219 — committed to gaelph/keystats by gaelph 7 months ago
I’m facing the same issue using heatmapjs in my Angular application.
Any suggestions on how to include this fix from package.json (eg. load the library from that fork) ?
EDIT: This seems to work:
"heatmap.js": "https://github.com/ionata/heatmap.js.git"instead of"heatmap.js": "^2.0.5"so how can this problem be solved in version 2.0.5
The fork shared by jakob-e works for me too. I’m using rollup to bundle everything. This has been open for some time. That fork is not on npm. What should be done next?
Same here. I found that problem occur only on prod env when all my scripts are bundled and “use strict” is on top of bundle.