html的svg插件,svg圆形进度条插件svg-gauge

svg-gauge是一款基于SVG的圆形进度条插件。该插件无任何依赖,可以轻松的制作出各种圆形进度条,以及圆形进度条的动画特效。

使用方法

HTML结构

最简单的按钮HTML结构如下。

CSS样式

.gauge-container {

width: 150px;

height: 150px;

display: block;

padding: 10px;

}

.gauge-container > .gauge > .dial {

stroke: #eee;

stroke-width: 2;

fill: rgba(0,0,0,0);

}

.gauge-container > .gauge > .value {

stroke: rgb(47, 227, 255);

stroke-width: 2;

fill: rgba(0,0,0,0);

}

.gauge-container > .gauge > .value-text {

fill: rgb(47, 227, 255);

font-family: sans-serif;

font-weight: bold;

font-size: 1em;

}

javaScript

// npm install

npm install svg-gauge

// Require JS

var Gauge = require("svg-gauge");

// Standalone

var Gauge = window.Gauge;

// Create a new Gauge

var cpuGauge = Gauge(document.getElementById("cpuSpeed"), {

max: 100,

// custom label renderer

label: function(value) {

return Math.round(value) + "/" + this.max;

},

value: 50,

// Custom dial colors (Optional)

color: function(value) {

if(value < 20) {

return "#5ee432"; // green

}else if(value > 40) {

return "#fffa50"; // yellow

}else if(value > 60) {

return "#f7aa38"; // orange

}else {

return "#ef4655"; // red

}

}

});

// Set gauge value

cpuGauge.setValue(75);

// Set value and animate (value, animation duration in seconds)

cpuGauge.setValueAnimated(90, 1);

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值