-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot assign to read only property 'data' of object #219
Comments
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. |
FYI – this fork worked for me |
I'm facing the same issue using heatmapjs in my Angular application. |
facing same issue , react rollup babel |
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? |
The fork shared by jakob-e is behind master by 12 commits.
|
Is there any progress on this one? Thanks |
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 version / usage bug
import HeatMap from '@/libs/heatmap.min.js';
// import '@/libs/heatmap.min.js';
const parentPage = document.getElementById('parentPage');
const heatMapObj = HeatMap.create({
container: parentPage,
radius: 30,
maxOpacity: .5,
minOpacity: 0,
blur: .75
}); // import HeatMap from '@/libs/heatmap.min.js';
import '@/libs/heatmap.min.js';
const parentPage = document.getElementById('parentPage');
const heatMapObj = h337.create({
container: parentPage,
radius: 30,
maxOpacity: .5,
minOpacity: 0,
blur: .75
});
const importScript = () => {
if(!window.h337) {
const script = document.createElement('script');
script.src = '/libs/heatmap.min.js';
const body = document.querySelector('body');
body.appendChild(script);
}
};
importScript();
const parentPage = document.getElementById('parentPage');
const heatMapObj = h337.create({
container: parentPage,
radius: 30,
maxOpacity: .5,
minOpacity: 0,
blur: .75
}); |
#344 pull request. |
so how can this problem be solved in version 2.0.5 |
Remove line 527 "img.data = imgData", or in the min version, locate this and delete it. That worked for me. |
你好,请问有解决了吗 |
This project appears to be abandoned. For anyone else experiencing this issue and using leaflet - switching to 'leaflet.heat' was easy enough. |
If you are using NPM patch-package, you could use the attached patch file to correct this in 2.0.5 directly in node_modules as part of your build scripts. |
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 ofImageData
object is being replaced directly in this part of the code. https://github.com/pa7/heatmap.js/blob/master/src/renderer/canvas2d.js#L280data
property seems to be read only on certain browser versions. To fix it, we need to delete this line becauseimgData
andimg.data
points to the same reference. Any modifications you do toimgData
is already reflected toimg.data
. I'll put up a PR soon.The text was updated successfully, but these errors were encountered: