Giter Site home page Giter Site logo

kenho1703 / angular-progress-arc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mathewbyrne/angular-progress-arc

0.0 2.0 0.0 340 KB

AngularJS directive for displaying a circular progress meter.

Home Page: http://mathewbyrne.github.io/angular-progress-arc/

License: MIT License

JavaScript 17.41% HTML 82.59%

angular-progress-arc's Introduction

angular-progress-arc

An AngularJS directive for displaying a circular progress meter.

Demo

Features

  • Displays a circular progress meter.
  • Utilises SVG for rendering.
  • Adjustable dimensions, color and thickness.
  • No additional dependencies outside of AngularJS.

Installation

This module can be installed using bower:

bower install angular-progress-arc --save

Otherwise, simply add the angular-progress-arc.min.js file to your project.

Usage

Include the script in your application and include the angular-progress-arc module as a dependency in your application module.

angular.module('myApp', ['angular-progress-arc']);

Add a progress-arc element to your application as required.

<progress-arc
    size="{integer}"
    stroke="{string}"
    stroke-width="{integer}"
    complete="{expression}"
    counter-clockwise="{string}"
    background="{string}">
</progress-arc>

Attributes

  • size defines the pixel width and height for the svg element. This defaults to 200.
  • stroke defines the color of the progress arc. This should be a valid stroke property for an SVG circle element. This defaults to black.
  • stroke-width defines the width of the progress arc line in pixels. This should be a value between 1 and size / 2. This defaults to 20.
  • complete is an expression that should evaluate to a float value between 0.0 and 1.0; where 0.0 is an empty progress arc, and 1.0 is a full ring.
  • counter-clockwise is a boolean value that will render the progress arc in a counter-clockwise direction. Any value Javascript would recognise as true will be treated as such, with the exception of the literal string false which will be treated as a boolean false.
  • background defines the color of the ring background. If not defined, no background is rendered.

Styling

As well as using attributes of the directive element, a progress arc can be styled using CSS.

// Use a more complex selector in your application to avoid styling other SVG elements.
circle {
    stroke: rgba(0, 0, 0, 0.1);
    stroke-linecap: round;
}

The stroke-dashoffset property is used to render the position of the progress arc, so adding a transition for this property will result in smoother transitions between progress values.

circle {
    transition: stroke-dashoffset 0.1s linear;
}

If you use CSS for styling, avoid setting the following properties that are used to calculate the progress arc position:

  • stroke-width
  • stroke-dasharray
  • stroke-dashoffset

Defaults

This module provides a service for configuring application-wide defaults for progress-arc directives. To change default values, inject the progressArcDefaultsProvider into your module's config method:

myApp.config(['progressArcDefaultsProvider', function (progressArcDefaultsProvider) {
    progressArcDefaultsProvider
        .setDefault('background', '#aaa')
        .setDefault('size', 300);
});

The values you can configure this way are size, strokeWidth, stroke and background.

License

angular-progress-arc is licensed under the MIT license. See LICENSE for details.

angular-progress-arc's People

Contributors

mathewbyrne avatar mathewbyrnejbi avatar rlogiacco avatar

Watchers

James Cloos avatar Ken Ho avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.