首页 > 其他分享 >heatmapts_simple-heatmap的使用

heatmapts_simple-heatmap的使用

时间:2023-04-15 23:45:00浏览次数:34  
标签:heatmapts oCanvas simple innerHeight innerWidth window heatmap radius 100

simple heat的使用


<script setup lang="ts">
import { SimpleHeat } from "simpleheat-ts";

import * as dat from "dat.gui";

let frame: number | null = null;

const oCanvas = document.createElement("canvas");
oCanvas.width = window.innerWidth * 0.75;
oCanvas.height = window.innerHeight * 0.75;
oCanvas.style.border = "5px solid red";

const data = [
  [0, 0, 100],
  [window.innerWidth * 0.1, window.innerHeight * 0.1, 100],
  [window.innerWidth * 0.2, window.innerHeight * 0.2, -100],
  [window.innerWidth * 0.3, window.innerHeight * 0.3, 100],
  [window.innerWidth * 0.4, window.innerHeight * 0.4, 100],
  [window.innerWidth * 0.5, window.innerHeight * 0.5, 100],
  [window.innerWidth * 0.6, window.innerHeight * 0.6, 100],
  [window.innerWidth * 0.7, window.innerHeight * 0.7, 100],
  [window.innerWidth * 0.75, window.innerHeight * 0.75, 100],
];

const heat = new SimpleHeat(
  document.createElement("canvas"),
  document.createElement("canvas")
);

heat.data(data);
heat.max(100);
document.body.appendChild(oCanvas);

draw();

function draw() {
  heat.draw(oCanvas.getContext("2d")!, 0.5);
  frame = null;
}

document.getElementsByTagName("canvas")[0].onmousemove = function (e) {
  heat.add([e.clientX, e.clientY, -100]);
  frame = frame || window.requestAnimationFrame(draw);
};
</script>

<template></template>

<style scoped></style>

heatmap-ts的使用


<script setup lang="ts">
import HeatMap from "heatmap-ts";

const oCanvas = document.createElement("canvas");
oCanvas.style.border = "5px solid red";

const heatMap = new HeatMap({
  maxOpacity: 0.6,
  radius: 50,
  blur: 0.9,
  canvas: oCanvas,
  width: window.innerWidth,
  height: window.innerHeight,
});

heatMap.setData({
  max: 100,
  min: 1,
  data: [
    {
      x: 0,
      y: 0,
      value: 100,
      radius: 10,
    },
    {
      x: window.innerWidth * 0.1,
      y: window.innerHeight * 0.1,
      value: 100,
      radius: 50,
    },
    {
      x: window.innerWidth * 0.2,
      y: window.innerHeight * 0.2,
      value: 100,
      radius: 100,
    },
    {
      x: window.innerWidth * 0.3,
      y: window.innerHeight * 0.3,
      value: 100,
      radius: 50,
    },
    {
      x: window.innerWidth * 0.5,
      y: window.innerHeight * 0.5,
      value: 100,
      radius: 20,
    },
    {
      x: window.innerWidth * 0.6,
      y: window.innerHeight * 0.6,
      value: 100,
      radius: 20,
    },
    {
      x: window.innerWidth * 0.7,
      y: window.innerHeight * 0.7,
      value: 100,
      radius: 20,
    },
    {
      x: window.innerWidth * 0.8,
      y: window.innerHeight * 0.8,
      value: 100,
      radius: 20,
    },
    {
      x: window.innerWidth * 0.9,
      y: window.innerHeight * 0.9,
      value: 100,
      radius: 20,
    },
    {
      x: window.innerWidth * 1.0,
      y: window.innerHeight * 1.0,
      value: 100,
      radius: 20,
    },
  ],
});

document.body.appendChild(oCanvas);
</script>

<template></template>

<style scoped></style>

标签:heatmapts,oCanvas,simple,innerHeight,innerWidth,window,heatmap,radius,100
From: https://www.cnblogs.com/zhuoss/p/17322284.html

相关文章

  • Django Admin SimpleUI 自定义列
    DjangoAdminSimpleUI的一些简单用法注意事项:自定义列会遍历所有取出来的数据,需注意先定义下模型#models.pyclassDog(models.Model):name=models.CharField(max_length=15,verbose_name='小狗名字')age=models.IntegerField(verbose_name='小狗年龄',defa......
  • django admin 使用SimpleUI自定义按钮弹窗框示例
    actions=['button_exeScript',]defbutton_exeScript(self,request,queryset):passbutton_exeScript.layer={#弹出层中的输入框配置#这里指定对话框的标题'title':'弹出层输入框',#提示信息......
  • POJ 3468 A Simple Problem with Integers(线段树区间更新)
    题目地址:POJ3468打了个篮球回来果然神经有点冲动。。无脑的狂交了8次WA。。居然是更新的时候把r-l写成了l-r。。。这题就是区间更新裸题。区间更新就是加一个lazy标记,延迟标记,只有向下查询的时候才将lazy标记向下更新。其他的均按线段树的来就行。代码如下:#include<iostream>#in......
  • SNMP(Simple Network Management Protocol)——简单网络管理协议
    SNMP(SimpleNetworkManagementProtocol)——简单网络管理协议 目录一、SNMP简介1.背景2.SNMP管理的网络架构二、SNMPMIB1.SNMPMIB简介2.MIB分类(1)公有MIB(2)私有MIB3.被管理设备的基本属性(1)对象表示符(2)对象的状态(3)对象的访问权限(4)对象的数据类型三、SNMPv1工作......
  • SimpleAdmin手摸手教学之:导入导出
    一、说明导入导出是系统中经常需要用到的功能,大部分系统的导入功能都是上传一个excel文件,然后导入成功就提示导入成功,失败就提示导入失败,顶多返回一个导入结果的excel,非常的不直观。如何设计一个优雅的导入让用户能非常直观的在数据还没导入进系统的时候看到有哪些数据是可以导入......
  • 09、OpenFoam中的PISO,SIMPLE和PIMPLE算法
    隐式:PISO半隐式:SIMPLE组合式:PIMPLE(PISO+SIMPLE)PISO算法PISO算法是一种常用于求解不可压缩流体流动问题的数值方法,它在OpenFOAM中被广泛应用。PISO算法的全称为PressureImplicitwithSplittingofOperators,即利用算子分裂的方法进行隐式求解压力和速度。PISO算法主要分为......
  • Simple Finance的表变化讲解
                  ......
  • 为ViewPager设置SimpleViewPagerIndicator
    说到ViewPagerIndicator,网上有很多专门的开源库;我这里重提一下,只是想试试它的实现方法;记录下来,可以以后快速的修改迭代~~~很简单的一个类:importandroid.content.Context;importandroid.graphics.Canvas;importandroid.graphics.Color;importan......
  • 基于上一篇实现的SimpleListPopupWindow<T>
    这次是个简单的PopupWindow,快速迭代用。importjava.util.List;importandroid.content.Context;importandroid.view.View;importandroid.widget.AdapterView;importandroid.widget.LinearLayout.LayoutParams;importandroid.widget.ListView;im......
  • SimpleAdmin手摸手教学之:插件管理
    一、前言在2.0的架构设计中,引入了插件的概念,目的就是为了解决代码臃肿问题,随着系统功能越来越多,System层的代码也越来越多,之前是以文件夹的方式区分功能模块,这样的话代码就过于集中,想找到某一个功能模块的代码就要翻好几个文件夹,不利于以后的开发和维护。所以在新的架构中,我将部......