javascript - 如何使用反应离子在图像上绘制点?
问题描述
我正面临使用 heatmap.js 在来自服务器端的图像上绘制带有动态点的热图的问题。
使用带有反应离子的 heatmap.js。
我可以在桌面视图上绘制点,但我想在移动视图上绘制它。
import React from "react";
import h337 from "heatmap.js";
import Image from './road.jpg'
import './styles.css'
interface IControlAreaProps {
location?: any;
state?: any;
history?: any;
}
const App: React.FC<IControlAreaProps> = () => {
const handleHeatmap = () => {
let heatmapInstance = h337.create({
container: document.querySelector('.heatmap'),
gradient: {
'1': 'blue',
},
});
let points: any = [
//with these point you can see the heatmap plotted on the image
{ x: 58, y: 63, value: 80 },
{ x: 28, y: 73, value: 90 },
{ x: 98, y: 83, value: 60 }
// but these point heat map are not ploting
// { x: 588, y: 625, value: 50 },
// { x: 828, y: 465, value: 60 },
// { x: 460, y: 447, value: 40}
];
let data = {
max: 100,
min: 0,
data: points
};
heatmapInstance.setData(data);
var div: any = document.getElementById('mydiv');
div.style.display = div?.style.display === "block" ? "none" : "block";
}
return (
<>
<button onClick={handleHeatmap} >
showHeatMap
</button>
<div id="mydiv" className="heatmap">
<img src={Image} alt="image"/>
</div>
</>
);
};
export default App;
我正在寻找如何使用动态点在图像上绘制热图的解决方案。我试过调整画布和图像的大小。
如果有任何其他方法或库可以在图像上绘制热图,那也可以。
解决方案
推荐阅读
- java - OpenTelemetry java - 行李传播
- c - 在C中返回两个字符串组合的函数
- json - 如果在 Kotlin(Android 工作室)中没有密钥,如何制作 JSON 数据的数据类?
- flutter - Flutter : blockprovider.of() 用上下文调用blockprovider.of() 用上下文调用
- bazel - 如何在 bazel 查询中获取未提交更改的文件内容?
- c++ - c++ 带打印的字符串生成器(cout)
- javascript - 无法加载 wasm URL 方案文件不受支持
- c++ - `std::filesystem::directory_iterator` 优雅地处理不存在的目录
- laravel - 关于在文件系统与数据库上存储 Laravel 文件上传的问题,以及如何在需要时存储在数据库而不是文件系统中
- python - python websockets,多个请求,为什么只收到请求?