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

arc-pie-chart

v1.2.10

Published

pie chart that can be divided into several steps

Downloads

39

Readme

Arc Pie Chart

downloads version dependencies typescript

pie chart that can be divided into several steps with Typescript

Install

npm install arc-pie-chart

Usage

It's just example

parageters

  • data : See the data format below.
  • totalDepth: your data's depth. (example is 3)
  • size: chart's px width
    • default is 500
    • you can change it by using css

declaration

import makePieChart from "arc-pie-chart";

const data = [...]

const chart = makePieChart(data, totalDepth, size); // svg tag <svg></svg>

React

import React, { useEffect, useRef } from "react";
import makePieChart from "arc-pie-chart";
import { data } from "./data";

function App() {
  const svg = useRef(null);
  const totalDepth = 3; // data's depth
  const size = 500; // px size

  useEffect(() => {
    if (svg.current) {
      svg.current.appendChild(makePieChart(data, totalDepth, size));
    }
  });

  return <div ref={svg} />;
}

export default App;

data format

  • You can create multi-level pie charts by connecting data arrays.
  • The sum of the percentages must be less than one hundred percent
const data = [
  {
    name: "INCOME",
    percentage: 55,
    color: "crimson",
    textColor: "black",
    data: [
      {
        name: "SALARY",
        percentage: 30,
        color: "crimson",
        textColor: "white",
      },
      {
        name: "BLOG",
        percentage: 30,
        color: "crimson",
        textColor: "white",
      },
      {
        name: "ETC",
        percentage: 40,
        color: "crimson",
        textColor: "white",
        data: [
          {
            name: "STOCK",
            percentage: 60,
            color: "crimson",
            textColor: "white",
          },
          {
            name: "GOLD",
            percentage: 40,
            color: "crimson",
            textColor: "white",
          },
        ],
      },
    ],
  },
  {
    name: "EXPENSE",
    percentage: 45,
    color: "#3BB6AE",
    textColor: "black",
    data: [
      {
        name: "EAT",
        percentage: 10,
        color: "#3BB6AE",
        textColor: "black",
      },
      {
        name: "LIFE",
        percentage: 20,
        color: "#3BB6AE",
        textColor: "black",
      },
      {
        name: "SHOPPING",
        percentage: 10,
        color: "#3BB6AE",
        textColor: "black",
      },
      {
        name: "BUS",
        percentage: 20,
        color: "#3BB6AE",
        textColor: "black",
        data: [
          {
            name: "FAST",
            percentage: 50,
            color: "#3BB6AE",
            textColor: "black",
          },
          {
            name: "SLOW",
            percentage: 50,
            color: "#3BB6AE",
            textColor: "black",
          },
        ],
      },
      {
        name: "HEALTH",
        percentage: 10,
        color: "#3BB6AE",
        textColor: "black",
      },
      {
        name: "CULTURE",
        percentage: 10,
        color: "#3BB6AE",
        textColor: "black",
      },
      {
        name: "ETC",
        percentage: 20,
        color: "#3BB6AE",
        textColor: "black",
      },
    ],
  },
];