npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-chart-race

v0.0.3

Published

Animated bar chart race for ReactJS.

Downloads

196

Readme

React Chart Race

The animated bar chart race helps you visualize your changing data in a wonderful way. It is quite easy to understand. A rising or decreasing bar moves up or down along with the animation.

Image

Features

  • The bars move in an animated way.
  • You can change all colors as you wish.
  • You can add as many bars as you want.
  • You can define individual colors for each bar.
  • The height of the field is calculated automatically based on the number of bars added.
  • The width of the bars is calculated proportionally according to the entered values.
  • Just setState for the animation to work.

Installation

npm install --save react-chart-race

Import

import ChartRace from 'react-chart-race';

Parameters

Name | Value | Default | Description --- | --- | --- | --- data | Array | [] | Data required for drawing the graph. backgroundColor | String | #f9f9f9 | The background color of the field. width | Number | 680 | The width of the field. padding | Number | 20 | The internal space of the field. itemHeight | Number | 38 | The height of a bar. gap | Number | 4 | Space between the bars from the outside. titleStyle | Style | { font: 'normal 400 13px Arial', color: '#212121' } | The style values of the title. valueStyle | Style | { font: 'normal 400 11px Arial', color: '#777' } | The style values of the value.

Simple Usage

An element must consist of 4 variables: id, title, value, color

<ChartRace data={[
  { id: 0, title: 'Ayfonkarahisar', value: 42, color: '#50c4fe' },
  { id: 1, title: 'Kayseri', value: 38, color: '#3fc42d' },
  { id: 2, title: 'Muğla', value: 76, color: '#c33178' },
  { id: 3, title: 'Uşak', value: 30, color: '#423bce' },
  { id: 4, title: 'Sivas', value: 58, color: '#c8303b' },
  { id: 5, title: 'Konya', value: 16, color: '#2c2c2c' }
]} />

Advanced Usage

import React, { Component } from 'react';
import ChartRace from 'react-chart-race';

export default class App extends Component{

  constructor(props){
    super(props);
    this.state = {
      data: []
    };
    this.handleChange();
    setInterval(() => {
      this.handleChange();
    }, 2000);
  }

  getRandomInt(min, max){
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
  }

  handleChange(){
    const data = [
      { id: 0, title: 'Ayfonkarahisar', value: this.getRandomInt(10, 90), color: '#50c4fe' },
      { id: 1, title: 'Kayseri', value: 38, color: '#3fc42d' },
      { id: 2, title: 'Muğla', value: this.getRandomInt(10, 90), color: '#c33178' },
      { id: 3, title: 'Uşak', value: this.getRandomInt(10, 90), color: '#423bce' },
      { id: 4, title: 'Sivas', value: 58, color: '#c8303b' },
      { id: 5, title: 'Konya', value: 16, color: '#2c2c2c' }
    ];
    this.setState({ data });
  }

  render(){
    return(
      <div>
        <ChartRace
          data={this.state.data}
          backgroundColor='#000'
          width={760}
          padding={12}
          itemHeight={58}
          gap={12}
          titleStyle={{ font: 'normal 400 13px Arial', color: '#fff' }}
          valueStyle={{ font: 'normal 400 11px Arial', color: 'rgba(255,255,255, 0.42)' }}
        />
      </div>
    );
  }

}

If you want, you can also integrate the new values of the data on a socket connection.

License

MIT