1.0.0 • Published 6 years ago

circle-progress-bar v1.0.0

Weekly downloads
3
License
-
Repository
-
Last release
6 years ago

Circle Progress Bar

A distinctive feature is the possibility of setting a conical gradient for progress bar.

Features:

  • Any number of colors
  • Possibility to setup animation and sizes
  • Possibility to control from api methods
  • Events

Usage Instructions

  1. Link file:
<script src="build/circle-progress-bar.min.js"></script>
  1. Add Markup
<canvas id="canvas" width="300" height="300"></canvas>
  1. Init progress bar
var canvas = document.getElementById('canvas');
var circleProgressBar = new CircleProgressBar(canvas, {
    colors: ['#0000FF', '#4B0082', '#9400D3']
});
// set initial value
circleProgressBar.setValue(0.9);

Options

OptionDefaultDescription
xcanvas.width / 2X position of circle
ycanvas.heigth / 2Y position of circle
colors['#9400D3', '#4B0082', '#0000FF']List of colors for gradient
radius120Radius of circle
lineWidth15Line width
frameInterval10Interval of rendering circle animation
frameStep0.1Step of arc length for one frame
startPosition-(Math.PI / 2)Start position of circle arc
lineCaproundValue of canvas.context.lineCap
trackLineColor#eeeColor of track line. Set null for remove it.
maxColorsCountByValue{ 0.05: 2,0.2: 2,0.3: 3, 0.4: 4, 0.6: 5 }Max colors in gradient by value

Methods

MethodParamsDescription
setValueintSetting value and drawing
getValueGetting value
setOptionsObjectSetting options
drawDraw progress bar for current value and options
clearClear progress bar from canvas

Events

EventDescription
circleProgressBar.afterDrawAfter drawing. e.detail.self - current instance
circleProgressBar.afterFrameDrawAfter drawing frame. e.detail.self - current instance, e.detail.progress - progress of drawing