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

@stevent-team/react-chartlet

v0.3.1

Published

A simple and tiny charting library for React

Downloads

1

Readme

🍩 React Chartlet

npm version minzip size

A simple and tiny React charting library

Warning This package is unstable and still in active development. You are more than welcome to contribute and make use of it but please note that there will be breaking changes

Installation

yarn add @stevent-team/react-chartlet

Supported Charts

  • [x] DonutChart
  • [x] BarChart
  • [x] LineChart
  • [ ] ScatterChart
  • [ ] PercentageChart
  • [ ] WordCloud
  • [ ] TimeSeries

Examples

Please note that all charts are responsive by default; they will grow to fill the width of their container, and have height set to 100%. You can set a specific size on them, however if you don't your chart may not show up due to it's height being 0.

TLDR: If your chart doesn't appear, try setting an explicit height for it or its container 😎

LineChart

import { Chartlet, LineChart } from '@stevent-team/react-chartlet'

const series = [[0, 0], [1, 4], [2, 3], [3, 5]]

const MyPage = () => (
  <Chartlet series={[series]} height={300}>
    <LineChart />
  </Chartlet>
)

DonutChart

import { Chartlet, DonutChart } from '@stevent-team/react-chartlet'

const MyPage = () => (
  <Chartlet categories={{ A: 10, B: 20 }} height={300}>
    <DonutChart />
  </Chartlet>
)

Legend

Note Legends are not rendered using SVGs so they are placed outside of the Chartlet component. This allows you to re-style them using flex or grid however you prefer.

import { Chartlet, DonutChart, Legend } from '@stevent-team/react-chartlet'

const categories = { A: 10, B: 20 }

export const MyPage = () =>
  <div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr' }}>
    <Chartlet categories={categories} height={250}>
      <DonutChart />
    </Chartlet>
    <Legend categories={categories} />
  </div>

API Reference

Types

| Data Type | Prop Name | Format | Example | Supported Charts | | --------- | --------- | ------ | ------- | ---------------- | | CategoricalData | categories | Record<string, number> | { a: 1 } | DonutChart, BarChart | | GroupedCategoricalData | groups | Record<string, number[]> | { a: [1, 2] } | BarChart | | SeriesData | series | [number, number][][] | [[[0, 0], [1, 1]]] | LineChart |

Context

Data props are shared to charts in the <Chartlet/> component using a context. However the <Legend/> should not be placed in a <Chartlet> and so must be explicitly passed data.

Generic Chart

The <GenericChart /> component allows dynamically choosing between different chart components using a type prop.

const DynamicChart = ({ data }) =>
  <Chartlet>
    <GenericChart type={data.isCategorical ? 'bar' : 'line'} />
  </Chartlet>

Docs

Note Coming soon... (in the short term, check out the prop interfaces for each chart)

Development

To test the components in this library, follow the steps below:

  1. Clone the repo onto your machine
  2. Run yarn to install dependencies
  3. Run yarn storybook to start Storybook

You can set up stories to test components using this documentation

Contributing

Issue contributions are greatly welcomed and appreciated!

For now, PR contributions are temporarily closed while react-chartlet remains unstable. Thank you for your patience :)

License

react-chartlet is licensed under MIT

Created with love by the Stevent Team 💙