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 🙏

© 2025 – Pkg Stats / Ryan Hefner

radial-bar

v0.2.2

Published

Javascript library for creating radial progress bars on canvas

Downloads

2,672

Readme

RadialBar (v.0.2.1)

Эта JavaScript библиотека позволяет создавать радиальные прогресс бары на canvas.

pic

Пример

 var canvas = document.getElementById('paper');
 var ctx = canvas.getContext('2d');

 var bar = new RadialBar(ctx, {
 	x: 500,
 	y: 500,
 	radius: 60,
 	lineWidth: 4,
 	lineFill: '#CCB566',
 	backLineFill: '#FB6929',
 	bgFill: '#F8FF8E',
 	progress: 100,
 	isShowInfoText: true,
 	infoStyle: '30px Arial',
 	infoColor: 'red'
 });

 // Update
 function loop() {
 	ctx.clearRect(0, 0, canvas.width, canvas.height);
 	
 	// добавляем      
 	bar.add(0.1);
 	
 	// перерисовываем
 	bar.update();

 	requestAnimationFrame(loop);
 }
 loop();

Чтобы начать

Чтобы создать новый прогресс бар

 var bar = new RadialBar(context, config);
  • context - это полученный методом 'getContext('2d') контекст канваса.
  • config - это объект с описанием конфигурация прогресс бара

Свойства config

  • x: Integer позиция центра окружности по x координате
  • y: Integer позиция центра окружности по y координате
  • angle: Integer задает угол наклона
  • radius: Integer радиус окружности
  • lineWidth: Integer ширина линии окружности (прогресс бар)
  • lineFill: String (Color) цвет заливки линии окружности (прогресс бар)
  • backLineFill: String (Color) цвет задний заливки (за линией окружности)
  • bgFill: String (Color) цвет самого прогресс бара (центр окружности)
  • progress: Integer (Percentage) значение в процентах от 0 до 100, позволяет указать на сколько процентов нужно заполить прогресс бар
  • isShowInfoText: Boolean показывать ли в центре прогресс в процентах (вид: value%)
  • infoStyle: String (FontStyle) позволяет указать стили для текста, как это делает свойство font в стандартном canvas API (например: '50px Arial')
  • infoColor: String (Color) позволяет указать цвет текста
  • isStop: Boolean Останавливает и запускает прогресс бар

Методы RadialBar

  • styles(config) - задает все свойства конфига (используется так же в конструкторе)
  • set(val) - устанавливает в прогресс баре значение val, где val число от 0 до 100
  • add(val) - добавляет значение val в прогресс бар, где val число от 0 до 100
  • subtract(val) - вычитает значение val в прогресс баре, где val число от 0 до 100
  • update() - вызывается после вызова set, add и subtract, чтобы обновить значения визуально на холсте
  • get() - возвращает строку типа 'value %', где value число от 0 до 100

Свойства RadialBar

  • все свойства, которые возможно записать в config
  • PERCENT_DEG - константа, которая ровняется 360/100 (1% от 360 грудусов)
  • degProgress - количество градусов, вычисляется так, progress (% загрузки) * PERCENT_DEG

Автор

Андрей Жевлаков (@AZbang)