简体   繁体   English

调整大小事件处理程序上的自适应heatmap.js

[英]Responsive heatmap.js on resize event handler

First of all, I am using ReactJS and heatmap.js library. 首先,我正在使用ReactJS和heatmap.js库。

The HTMLDivElement that is used as heatmap.js entry point should be responsive. 用作heatmap.js入口点的HTMLDivElement应该是响应式的。 At every window resize it adjusts based on the current window size. 每次调整窗口大小时,它都会根据当前窗口大小进行调整。

However, the canvas created by the heatmap.js library object takes the initial dimensions of the div, so it's size remains the same. 但是,heatmap.js库对象创建的画布采用div的初始尺寸,因此其大小保持不变。

How could I make the children canvas responsive too? 我怎样才能使孩子们的画布也能响应呢?

The heatmap.js config JSON is the following: heatmap.js 配置 JSON如下:

this.heatmap = Heatmap.create({
  container: this.image
});

The variable this.image is a reference to a HTMLDivElement that it is given dynamically the width and height attributes. 可变this.image是,它是动态给出的宽度和高度属性一个HTMLDivElement的参考。

<div  style={{ width: `${width}px`, height:`${height}px`}} />

*If you're not familiar with JSX syntax, I could transform it into plain HTML/CSS/JS. *如果您不熟悉JSX语法,可以将其转换为纯HTML / CSS / JS。

一种解决方案是将画布设置为高度和宽度的100%,但包含在响应式<div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM