Socket
Socket
Sign inDemoInstall

react-simple-heatmap

Package Overview
Dependencies
8
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-simple-heatmap

A simple React component to create responsive heatmap.


Version published
Maintainers
1
Created

Readme

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

Last updated on 20 Mar 2019

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc