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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pie-render

v1.0.1

Published

A simple JavaScript library that visualizes remaining percent and used values as a circular pie on a HTML canvas element.

Readme

pie-render

A simple JavaScript library that visualizes remaining percent and used values as a circular pie on a HTML canvas element.

About

pie-render draws a circular pie on an canvas. The pie gradually shrinks as you add values against a chosen base amount. Unlike traditional pie charts used for static data visualization, pie-render is designed for scenarios where you want to visualize the remaining capacity. This makes it perfect for budgets, storage usage, displaying remaining lives in games, calorie tracking and more.

Features

  • Create a pie, add values and get visual representation of what's remaining.
  • Add a value and watch it convert to a slice of the pie.
  • Set boundaries and colours for "warning" and "danger" states.
  • Customize the appearance to match your style.
  • No external libraries needed.

Usage and Example

The package need a HTML5 canvas element to render the pie on. Create a canvas element in your HTML

<canvas id="canvasElement" width="240" height="240"></canvas>

Import the PieMeter class and collect the canvasElement.

import { PieRender } from 'pie-render'

const canvasElement = document.getElementById('canvasElement')

// Create a initial pie with default values.
const pieRender = new PieRender(canvasElement, 200) // Base value of 200

// Customize the pie.
pieRender.setPieBoundaries(60, 30) // Warning at 60%, danger at 30%
pieRender.createSlice(80) // Add a slice of 80 
pieRender.displayPercentageText(true) // Show remaining percentage text
pieRender.setFontColour('#ff0000') // Custom font colour
pieRender.setFontSize(50) // Custom font size

Default pie example

Default pie at 60% remaining Default pie at 45% remaining Default pie at 5% remaining

Custom pie example

Custom pie with text Custom pie without text

API

import { PieRender } from 'pie-render'

Constructor

new PieRender(canvasElement, baseValue)
Initialize with a HTML5 canvas element and a base value. The base value must be a positive number greater than zero. Draws the initial circle that represents 100% of the base value and the pie.

Methods

createSlice(inputValue)
Adds a value, coverts it to percent and radians/angles and draws it as a slice on the circle. Collects and stores the colour and the start and end angle of the slice. Redraws the pie on the canvas.

setPieBoundaries(warningPercent, dangerPercent)
Set the boundary in percent for when to reach warning and/or danger. The percent value for when the state will change from "ok" to "warning". The percent value for when the state will change from "warning" to "danger". Redraws the pie on the canvas.

setPieColour(hexColour)
Sets the base colour in hex colour code of the pie. Redraws the pie on the canvas.

setSliceColour(hexColour)
Sets the colour in hex colour code of a created slice that will be represented as a "removed" piece of the pie. Redraws the pie on the canvas.

setStateColours(warningColour, dangerColour)
Sets the colours in hex colour code for the 'warning' and 'danger' state of the pie. Redraws the pie on the canvas.

displayPercentText(display = false)
Determines whether to display text on canvas or not. True to display. Redraws the pie on the canvas.

setFontColour(hexColour)
Sets the colour in hex colour code of the text on the canvas. Redraws the pie on the canvas.

setFontSize(fontSize)
Sets the size in px of the text drawn on the canvas. Redraws the pie on the canvas.

getCurrentStateOfPie()
Returns an object with the current colour settings, pie boundaries, angles, text settings and remaining values. Redraws the pie on the canvas.

Installation

Install the package using npm:

npm install pie-render

Requirements

This package requires ES6 module and HTML5 support.

Testing

The package has been continuously tested throughout development by manual tests in a test application. Further testing is required to ensure the quality of this library.

See testreport for details.

Versioning

This project uses Semantic Versioning.

Getting involved

Please read the Contribution Guide for instructions on how to contribute to this project.

Author

Mathilda Segerlund - Web Development student at Linnaeus University, Sweden.

License

This project is licensed under the MIT License

Feedback

For further questions, feedback or suggestions, feel free to e-mail me!