easy-pie-chart.
trackColor · behind the bar lineWidth · px scaleColor · 24 ticks
0you draw this

One Metric.
Full control

A canvas ring for a single value. Every part is an option, and the center is yours to fill.

73
$ npm install easy-pie-chart

Or a script tag: unpkg.com/easy-pie-chart

Three ways in

Pick your entry point

The core is framework-agnostic. jQuery is an optional second entry point, never a dependency.

ES modules

import { EasyPieChart }
  from 'easy-pie-chart';

const chart = new EasyPieChart(el, {
  barColor: '#ef1e25',
});
chart.update(65);

Script tag

<!-- exposes window.EasyPieChart -->
<script src="easypiechart.min.js">
</script>

new EasyPieChart(el, {
  size: 140,
}).update(65);

jQuery

$('.chart').easyPieChart({
  barColor: '#10b981',
});

$('.chart')
  .data('easyPieChart')
  .update(42);

Put your own number in the middle

The chart draws the ring only. Position an element over it and update it from onStep. this.el is the host element.

Live

Turn the knobs

Every change below is the real library redrawing, and the code is what you would write to get it.

150
10
360
0
68

Since 3.1

Not only percentages

GaugearcLength 180
0
Custom max180 of max 250
GradientbarColor fn
Fill + borderfillColor

Reference

Options

Anything except the callbacks can also be set as a data-* attribute, which wins over the options object, so one call can configure many charts.

Constructor options
OptionDefaultDescription
barColor'#ef1e25'Color string, canvas gradient/pattern, or (value) => style
trackColor'#f9f9f9'Track behind the bar, or false
trackBorderColorfalseHairline along both edges of the track
fillColorfalseFills the disc inside the ring
scaleColor'#dfe0e0'Tick color, or false
scaleLength5Tick length in px
scaleCount24Number of ticks
lineCap'round'butt, round or square
lineWidth3Bar width in px
trackWidthlineWidthTrack width in px
size110Square, in px
rotate0Rotation in degrees
arcLength360Sweep in degrees. 180 gives a gauge
max100Value that fills the bar
responsivefalseFollow the host element's size
canvasClass'easy-pie-chart-canvas'Class on the generated canvas
animate{duration:1000, enabled:true}A number, false, or a (from,to) => ms duration
easingquadratic(t,b,c,d); the 2.x five-argument form and jQuery easing names still work
onStart / onStep / onStopnoneBound to the chart, so this.el works

Reference

Instance

Methods and properties
MemberReturnsDescription
update(value)thisAnimate, or jump when animation is off. Ignores NaN
setOptions(options)thisApply new options and redraw at the current value
stop()thisHalt a running animation at the current frame
enableAnimation() / disableAnimation()thisToggle animated updates
destroy()voidCancel animation, remove the canvas, stop observing
valuenumberCurrent value
options / elobject / elementResolved options, host element
rendererIRenderergetCtx() / getCanvas() for gradients

Upgrading

2.x → 3.x

3.x is a TypeScript rewrite. Existing jQuery and vanilla configurations keep working: data-* precedence, easing names and the 2.x easing signature are all still honored.

Still the same

$.fn.easyPieChart, data-percent, every option above, this.el inside callbacks, and the EasyPieChart global.

Gone

The AngularJS 1.x directive, Bower and Meteor packaging, and the IE 7/8 excanvas path. Licensing is MIT only.

AngularJS

A drop-in directive is in the Readme, or stay on 2.1.7, which remains on npm.