Giter VIP home page Giter VIP logo

vue-circle-progress's Introduction

vue-circle-progress

A Vue.js component to draw animated circular progress bars

Draw animated progress circle like below,


Install

// For Vue.js 2.0+
npm install vue2-circle-progress

Usage

  1. Import the module
  2. Register it as a component as you would any other Vue component
  3. Use it within your template

Example

<template>
  <div id="app">
    <p>
      A Vue.js component to draw animated circular progress bars!
    </p>
      <vue-circle
        :progress="50"
        :size="100"
        :reverse="false"
        line-cap="round"
        :fill="fill"
        empty-fill="rgba(0, 0, 0, .1)"
        :animation-start-value="0.0"
        :start-angle="0"
        insert-mode="append"
        :thickness="5"
        :show-percent="true"
        @vue-circle-progress="progress"
        @vue-circle-end="progress_end">
          <p>Slot!</p>
      </vue-circle>
  </div>
</template>

<script>
  import VueCircle from 'vue2-circle-progress'
  export default {
    components: {
      VueCircle
    },
    data(){
      return{
        fill : { gradient: ["red", "green", "blue"] },
      }
    },
    methods:{
      progress(event,progress,stepValue){
        console.log(stepValue);
      },
      progress_end(event){
        console.log("Circle progress end");
      }
    }
  }
</script>

Props

Follwing props are used while initialization

Note : Only progress is a required prop. Others are optional

Prop Name Type Description
progress (required) Number Total progress of circle (filled area)
size Number Size of circle
Default : 200
reverse Boolean Reverse animation and arc draw
Default:false
line-cap String Arc line cap: "butt", "round" or "square"
Default: "butt"
fill Object The arc fill config. You may specify next:
- "#ff1e41"
- { color: "#ff1e41" }
- { color: 'rgba(255, 255, 255, .3)' }
- { gradient: ["red", "green", "blue"] }
- { gradient: [["red", .2], ["green", .3], ["blue", .8]] }
- { gradient: [ ... ], gradientAngle: Math.PI / 4 }
- { gradient: [ ... ], gradientDirection: [x0, y0, x1, y1] }
- { image: "http://i.imgur.com/pT0i89v.png" }
- { image: imageInstance }
- { color: "lime", image: "http://i.imgur.com/pT0i89v.png" }
Default: { gradient: ["#3aeabb", "#fdd250"] }
empty-fill String Color of the "empty" arc. Only a color fill supported by now
Default: "rgba(0, 0, 0, .1)"
animation Mixed Animation config. See jQuery animations.
You may also set it to false
Default: { duration: 1200, easing: "circleProgressEasing" }
"circleProgressEasing" is just a ease-in-out-cubic easing
animation-start-value Number Default animation starts at 0.0 and ends at specified value. Let's call this direct animation. If you want to make reversed animation then you should set animationStartValue to 1.0. Also you may specify any other value from 0.0 to 1.0
Default: 0.0
start-angle Number Initial angle (for 0 value)
Default: -Math.PI
insert-mode String Canvas insertion mode: append or prepend it into the parent element
Default: "prepend"
thickness Number Width of the arc. By default it's automatically calculated as 1/14 of size but you may set your own number
Default: "auto"
show-percent Boolean Show loaded percentage inside circle. If inner-text property is set then percentage will not be shown.
Default : true

Events

Events emitted by the component to the parent.

Event Name Description
vue-circle-init(event) This event is emmited after the circle is initialized
vue-circle-progress(event,progress,stepValue) This event is emitted on every progress step
vue-circle-end(event) This event is emitted after completing progress

Methods

Methods you can call on the component.

Method Description
updateProgress(value) It will update component progress value and animate the change. It doesn't redraw the widget.
updateFill(fill) It will update component fill color.

Using Methods

Methods can be called from your parent component by making use of the special tag "ref".

When you initialize the component add a unique ID to the component using the ref tag, like this

<vue-circle ref="myUniqueID"></vue-circle>

Then from your parent Vue instance, you can call the methods by using the following:

this.$refs.myUniqueID.updateProgress(21);
this.$refs.myUniqueID.updateFill("#ff1e41");

Development

If you feel you can make this better, you are welcome to contribute. I'd love to see your ideas.

# install dependencies
npm install

# serve example at localhost:8080
npm run dev

# build any changes made
npm run build

Thanks

This is a Vue2 component built with wrapper around this library Thanks to Rostyslav Bryzgunov.

vue-circle-progress's People

Contributors

ajinkyabapat avatar kolchurinvv avatar skinnyjames avatar vrajroham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-circle-progress's Issues

Not working with runtime-only build

When using this in new Quasar, nothing renders and dev server throws

`[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

found in

--->
...`

I found out more packages have this issue and that it should be configured on package level. Package should pre-compile templates before shipping (otherwise I would need to use build with compiler, which is bigger and not good practice). I would submit a PR but I am not sure how to configure it, since I never wrote any Vue plugin.

Refactor ideas

commit - 72ce405

Trying to do some cleanup of possibly unnecessary properties, tags, and css rules - but I don't want to change something that was intended to be a particular way for a reason.

'this.$refs.myProgress.updateFill()' is not a function

I'm getting this error when I'm trying to update color of vue2-circle-progress component on data change by using updateFill() method of this component. But it gives me error. While the updateProgress() method is working fine.
Please help me with this.

Disappear for a moment on route change

I suggest that you should use afterDestroy instead beforeDestroy for removing an element, because when $route changes, element disappear before other content do and it looks laggy.

Method to update fill color

Hey, how are you guys? What an awesome components...

I'm wondering if it's possible to update my fill color after render.

Thanks.

background color

Is there a way to set a color to the inner background of the circle ?

Using with SSR. Error "ReferenceError: window is not defined"

My project use SSR.
I install vue-circle-progress but don`t use component any where.
I get error "ReferenceError: window is not defined"

It can be fixed easily. Just replace

var $ = require('jquery-easing');

to

const $ = typeof window !== 'undefined' ? require('jquery-easing') : null

Method for stopping progress?

As far as I can tell, once you call updateProgress() on your ref, this thing is off and running and there's no stopping it. Since it's supposed to be a progress bar, shouldn't there be a way to stop/pause the progress?

InnerText?

Hey guys, what happened to the innerText prop?

Possible re-license to MIT?

What about to change license to MIT? I don't really understand why is this under GPL because it is basically wrapper around MIT library using MIT/BSD tools. GPL makes it impossible to use for many projects. Did I miss some GPL lib?

Memory Leak

Pretty heavy memory leak when including the library.
Probably jQuery elements not being garbage collected.

"progress" doesn't v-bind properly

Lets say I bind progress like this:

:progress = "changing_value"

The first time upon loading works perfectly, however, when the "changing_value" changes, :progress is not updated accordingly. Is there anything that I am doing wrong? Appreciate the help :)

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.