Skip to content
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

Open
SVPA-CharlieSantos opened this issue Sep 1, 2016 · 15 comments · Fixed by doxo/heatmap.js#1
Open

Cannot assign to read only property 'data' of object #219

SVPA-CharlieSantos opened this issue Sep 1, 2016 · 15 comments · Fixed by doxo/heatmap.js#1

Comments

@SVPA-CharlieSantos
Copy link

When using heatmap.js on certain browsers, this error Cannot assign to read only property 'data' of object shows up.
screen shot 2016-09-01 at 11 18 47 am

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.

@kmlwlkwk
Copy link

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.

@jakob-e
Copy link

jakob-e commented May 2, 2017

@njifares
Copy link

njifares commented Aug 8, 2019

I'm facing the same issue using heatmapjs in my Angular application.

patskot added a commit to ionata/heatmap.js that referenced this issue Nov 4, 2019
@shmilyoo
Copy link

facing same issue , react rollup babel

@subtext916
Copy link

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?

@ascandal
Copy link

ascandal commented Jul 16, 2020

The fork shared by jakob-e is behind master by 12 commits.

This branch is 1 commit ahead, 12 commits behind pa7:master.

@theusner-thing
Copy link

theusner-thing commented Apr 23, 2021

Is there any progress on this one?
The fix removed img.data replacement due to the following issue seem to do the trick. We tested this in our environment (Angular 8)

Thanks

@Cristy94
Copy link

Cristy94 commented Jul 7, 2021

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"

@xgqfrms
Copy link

xgqfrms commented Dec 6, 2021

heatmap.js version / usage bug

heatmap.js v2.0.5

  1. import errors ❌
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
});
  1. window.h337 ok ✅
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
});

@ridweng
Copy link

ridweng commented Dec 22, 2021

#344 pull request.
Should be fixing this issue.

@iaaseihy
Copy link

so how can this problem be solved in version 2.0.5

@ridweng
Copy link

ridweng commented May 12, 2022

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.

@chen766
Copy link

chen766 commented Dec 26, 2022

同样在这里。我发现当我所有的脚都被抓绑定并“use strict”位在抓绑定包之时,问题只发生在 prod env 上。

你好,请问有解决了吗

@lobaak
Copy link

lobaak commented Apr 5, 2023

This project appears to be abandoned. For anyone else experiencing this issue and using leaflet - switching to 'leaflet.heat' was easy enough.
https://www.npmjs.com/package/leaflet.heat

dalen added a commit to dalen/killboard that referenced this issue Jul 29, 2023
gaelph added a commit to gaelph/keystats that referenced this issue Dec 4, 2023
@Nexudus
Copy link

Nexudus commented Mar 6, 2024

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.

heatmap.js+2.0.5.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.