You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-simple-heatmap

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simple-heatmap

A simple React component to create responsive heatmap.

1.1.3
Source
npmnpm
Version published
Weekly downloads
20
81.82%
Maintainers
1
Weekly downloads
 
Created
Source

react-simple-heatmap

A simple React component to create responsive heatmap. The heatmap take the height and width of it's parent element.

NPM JavaScript Style Guide

Install

npm install react-simple-heatmap

or

yarn add react-simple-heatmap

Demo

Here is a simple preview.

Properties

NameTypedescriptionexampledefaultisRequired
data2D Array of numbers2D Matrix of numbres[[10,12,33], [2,45,31], [16, 32, 29]]undefinedtrue
bgColorStringMain color using RGB format"rgb(255, 17, 17)""rgb(24, 144, 255)"false
showDataBolleanDisplay data inside each cells.truefalsefalse
showLegendBolleanDisplay the heatmap legend.truefalsefalse
onClickFunctionAdding an handler to cell click(data) => console.log(data)undefinedfalse
borderedBolleanDisplay a border on the heatmap.falsetruefalse

Usage

import React, { Component } from "react"

import Heatmap from "react-simple-heatmap"

export default class App extends Component {

  render() {

    return (
      <div
        style={{ height: "500px", width: "500px" }}>
        <Heatmap
          data={ data }  // 2D array of numbers
        />
      </div>
    );
  }
}

Example

import React, { Component } from 'react'
import Heatmap from 'react-simple-heatmap'

import './App.css';

// Creating a 10 x 10 array of random numbers
const size = 10;
const data = [];
for(let i = 0; i < size; i++){
  const temp = [];
  for(let i = 0; i < size; i++){
    temp.push(Math.round(Math.random() * 100) / 100);
  }
  data.push(temp);
}

export default class App extends Component {

  render() {
    return (
      <div style={{ marginTop: "4rem" }}>
        <div style={{ height: "500px", width: "500px" }}>
          <Heatmap
            showData={ true }
            showLegend={ true }
            bgColor={ "rgb(255, 17, 17)" }
            data={ data }
            onClick={ (data) => console.log(data) }
					/>
        </div>
      </div>
    );
  }
}

Screenshot

Alt text

License

MIT © JulienRioux

FAQs

Package last updated on 20 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.