Skip to content

Heatmap truncated when zsmooth="fast" #6564

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

Closed
lvlte opened this issue Apr 12, 2023 · 0 comments · Fixed by #6565
Closed

Heatmap truncated when zsmooth="fast" #6564

lvlte opened this issue Apr 12, 2023 · 0 comments · Fixed by #6565
Labels
bug something broken

Comments

@lvlte
Copy link
Contributor

lvlte commented Apr 12, 2023

When the number of bricks to draw horizontally and/or vertically is larger than the computed imageWidth and/or imageHeight (respectively), then the heatmap is not rendered correctly, it is truncated somehow (actually the image being drawn has the proper dimensions but there are dead pixels), see for example this pen.

Capture

While this is an edge case, after investigation I found a bug in the code responsible for drawing bricks on the canvas. In fact, this bug affects performance (ie. drawing dead pixels outside the canvas), and when the conditions are met (ie. high-res heatmaps rendered in a smaller area), can lead to the issue described above.

So, when zsmooth="fast", the canvas is set to have dimensions n*m :

if(zsmooth === 'fast') {
	canvasW = n;
	canvasH = m;
} else {
	canvasW = imageWidth;
	canvasH = imageHeight;
}

The issue is that the pixel array which is used for both zsmooth best|fast is not set properly as it should be specific to these dimensions, instead it always assume imageWidth * imageHeight :

if(zsmooth) { // best or fast, works fastest with imageData
	var pxIndex = 0;
	var pixels;

	try {
		pixels = new Uint8Array(imageWidth * imageHeight * 4);
	} catch(e) {
		pixels = new Array(imageWidth * imageHeight * 4);
	}

Same here when creating imageData.

And in the for loop that fills the pixel array, imageWidth is used instead of n.

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

Successfully merging a pull request may close this issue.

2 participants