Giter VIP home page Giter VIP logo

heatmap's Introduction

heatmap

热力图渲染插件

本款插件可以用于渲染热力图,效果:

热力图效果

安装

<script src="./heatmap.js"></script>

or

import HeatMap from './heatmap'

用法

new HeatMap(ctx, data); // 使用默认配置

new HeatMap(ctx, data, config); // 使用自定义配置
参数 类型 描述
ctx Object 画布 context2d 对象
data Array 数据数组
config Object 可选配置

实例化后会在 ctx 对象的画布元素上绘制出热力图图像。

热力图图像的数据有一定的结构要求,如下:

data 的数据结构

[
  {
    x: 100, // 横轴X坐标
    y: 200, // 纵轴y坐标
    value: 20, // 值
    radius: 5 // 可选,自定义半径
    blur: 0.5 // 可选,自定义透明区域范围
  }, {
  ...
  }
  ...
]

该结构没有设计配置入口(我一直认为越少配置越好),修改结构需要调整源码。

配置

配置项 类型 默认值 描述
blur Number 0.75 圆的透明区域范围
radius Array [10, 20] 圆的默认半径取值范围
gradient Object - 调色盘颜色

gradient 默认值如下:

gradient: {0.25: 'rgb(0,0,0)', 0.55: 'rgb(0,255,0)', 0.85: 'yellow', 1.0: 'rgb(255,0,0)'}

描述中所说的圆,是每条数据对应到热力图图像中的圆形。

热力图生成原理

本插件使用的原理与 pa7/heatmap.js 项目基本相同,欲了解详细可查看我写的一篇文章:

传送门

Thanks

heatmap's People

Contributors

ajccom avatar

Watchers

 avatar  avatar

Forkers

deol fqs617

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.