easypiechart ajax,GitHub - rendro/easy-pie-chart: easy pie chart is a lightweight plugin to draw sim...

easy-pie-chart

Lightweight plugin to render simple, animated and retina optimized pie charts

4de90dbca4abea077b3f5cf994573c2e.png

9b48daf7fd75b8842b61a901d4d220c4.png

3e581f7729e012ea2804ba22259d2e73.png

68747470733a2f2f67612d626561636f6e2e61707073706f742e636f6d2f55412d34363834303637322d312f656173792d7069652d63686172742f726561646d65

Features

7b20fb3f99893451ee3d8c2a3f996569.png

highly customizable

very easy to implement

resolution independent (retina optimized)

uses requestAnimationFrame for smooth animations on modern devices and

works in all modern browsers, even in IE7+ with excanvas

framework support

Vanilla JS (no dependencies) (~872 bytes)

jQuery plugin (~921 bytes)

Angular Module (~983 bytes)

Get started

Installation

You can also use bower to install the component:

$ bower install jquery.easy-pie-chart

jQuery

To use the easy pie chart plugin you need to load the current version of jQuery (> 1.6.4) and the source of the plugin.

73%

$(function() {

$('.chart').easyPieChart({

//your options goes here

});

});

Vanilla JS

If you don't want to use jQuery, implement the Vanilla JS version without any dependencies.

73%

var element = document.querySelector('.chart');

new EasyPieChart(element, {

// your options goes here

});

AngularJS

var app = angular.module('app', ['easypiechart']);

app.controller('chartCtrl', ['$scope', function ($scope) {

$scope.percent = 65;

$scope.options = {

animate:{

duration:0,

enabled:false

},

barColor:'#2C3E50',

scaleColor:false,

lineWidth:20,

lineCap:'circle'

};

}]);

Options

You can pass these options to the initialize function to set a custom look and feel for the plugin.

Property (Type)

Default

Description

barColor

#ef1e25

The color of the curcular bar. You can either pass a valid css color string, or a function that takes the current percentage as a value and returns a valid css color string.

trackColor

#f2f2f2

The color of the track, or false to disable rendering.

scaleColor

#dfe0e0

The color of the scale lines, false to disable rendering.

scaleLength

5

Length of the scale lines (reduces the radius of the chart).

lineCap

round

Defines how the ending of the bar line looks like. Possible values are: butt, round and square.

lineWidth

3

Width of the chart line in px.

size

110

Size of the pie chart in px. It will always be a square.

rotate

0

Rotation of the complete chart in degrees.

animate

object

Object with time in milliseconds and boolean for an animation of the bar growing ({ duration: 1000, enabled: true }), or false to deactivate animations.

easing

defaultEasing

Easing function or string with the name of a jQuery easing function

Callbacks

All callbacks will only be called if animate is not false.

Callback(params, ...)

Description

onStart(from, to)

Is called at the start of any animation.

onStep(from, to, currentValue)

Is called during animations providing the current value (the method is scoped to the context of th eplugin, so you can access the DOM element via this.el).

onStop(from, to)

Is called at the end of any animation.

Plugin api

jQuery

$(function() {

// instantiate the plugin

...

// update

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

...

// disable animation

$('.chart').data('easyPieChart').disableAnimation();

...

// enable animation

$('.chart').data('easyPieChart').enableAnimation();

});

Vanilla JS

// instantiate the plugin

var chart = new EasyPieChart(element, options);

// update

chart.update(40);

// disable animation

chart.disableAnimation();

// enable animation

chart.enableAnimation();

Using a gradient

new EasyPieChart(element, {

barColor: function(percent) {

var ctx = this.renderer.getCtx();

var canvas = this.renderer.getCanvas();

var gradient = ctx.createLinearGradient(0,0,canvas.width,0);

gradient.addColorStop(0, "#ffe57e");

gradient.addColorStop(1, "#de5900");

return gradient;

}

});

AngularJS

For a value binding you need to add the percent attribute and bind it to your controller.

RequireJS

When using RequireJS you can define your own name. Examples can be found in the demo/requirejs.html.

Browser Support

Native support

Chrome

Safari

FireFox

Opera

Internet Explorer 9+

Support for Internet Explorer 7 and 8 with excanvas polyfill.

Test

To run the test just use the karma adapter of grunt: grunt test

Credits

Thanks to Rafal Bromirski for designing this dribble shot which inspired me building this plugin.

Copyright

Copyright (c) 2015 Robert Fleischmann, contributors. Released under the MIT, GPL licenses

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值