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-simply-donut

v2.0.4

Published

A simple and customizable donut chart for React

Downloads

67

Readme

Easily integrate delightful and lightweight donut charts into your React applications with "React Simply Donut." This simple-to-use package provides a hassle-free way to add visually appealing donut charts to your projects.

Table of content

MIT License npm npm package minimized gzipped size (select exports) npm

Why

I had difficulty integrating a simple donut into an application. Therefore, I created one myself – simple and lightweight – and finally shared it.

Demo 💥

You can play with the demo here

Installation 🏗

Install react-simply-donut with npm, run:

npm i react-simply-donut

or if you prefer, you can use yarn:

yarn add react-simply-donut

Usage ✏

Here is a minimal example of using the package:

import React from "react";
import { SimplyDonut } from "react-simply-donut/donuts";
import { SimplyLegend } from "react-simply-donut/legends";

const data = [
  {
    value: 123,
    name: "value1",
  },
  {
    value: 97,
    name: "value2",
  },
  {
    value: 265,
    name: "value3",
  },
];

const DonutAndLegend = () => {
  return (
    <div>
      <div>
        <SimplyDonut data={data} />
      </div>
      <div>
        <h3>Legend title</h3>
        <SimplyLegend data={data} />
      </div>
    </div>
  );
};

API 🔗

SimplyDonut

This is the main component of the package

export type TDonutData = {
  name: string; // Donut section name
  value: number; // Donut section value
  color?: string; // Donut section color in hexadecimal format
};

export type TSimplyDonut = {
  data: TDonutData[]; // Data given for the entire donut chart
  size?: "sm" | "md" | "lg"; // Size of the donut chart
  inset?: {
    color?: string; // Color of the inner dot in hexadecimal format (default: "#cbd5e1")
    size?: number; // Donut thickness in percentage (between 5 and 45) (default: 12)
  };
};

const SimplyDonut = (props: TSimplyDonut) => {};

🚨 If the size property is not provided, the chart will extend to the boundaries of the parent block. To do this, the parent block must have a defined width and height, otherwise the graphic will not appear or will be completely flat.

SimplyPie

Note that is the same component than SimplyDonut without the inset props.

export TSimplyPie = Pick<TSimplyDonut, "data" | "size">;

// Pick<TSimplyDonut, "data" | "size"> type is equal to :
{
  data: TDonutData[]; // Data given for the entire pie chart
  size?: "sm" | "md" | "lg"; // Size of the pie chart. If not provided, look at the warning above.
};

const SimplyPie = (props: TSimplyPie) => {};

SimplyCircleProgressBar

This component displays a circle progress bar with your score

export type TSimplyCircleProgressBar = Pick<TSimplyDonut, "size" | "inset"> & {
  progress: number; // Value of the of the progress bar
  color?: string; // Color of the progress bar in hexadecimal format (default: "#FF5733")
  displayScore?: boolean; // Display the score inside the circle (default: true)
  remainingPortionOpacity?: number; // Apply a colored opacity on the remaining percentages (between 0 and 1 - based on the given color - default: 0.5)
};

// Pick<TSimplyDonut, "size" | "inset"> type is equal to :
{
  size?: "sm" | "md" | "lg"; // Size of the pie chart. If not provided, look at the warning above.
  inset?: {
    color?: string; // Color of the inner dot in hexadecimal format (default: "#cbd5e1")
    size?: number; // Donut thickness in percentage (between 5 and 45) (default: 12)
  };
};

const SimplyCircleProgressBar = (props: TSimplyCircleProgressBar) => {};

SimplyLegend

export type TSimplyLegend = {
  data: TDonutData[]; // data given for the entire donut chart (see SimplyDonut for more details)
  showPercentage?: boolean; // Display the corresponding percentage next to the value (default: false)
};

const SimplyLegend = (props: TSimplyLegend) => {};

Contributing

Contributors are welcome, feel free to submit a new pull request to help improve react-simply-donut.

License ©

MIT © Kimor44