-
Notifications
You must be signed in to change notification settings - Fork 0
/
progresscircle.css
90 lines (76 loc) · 2.07 KB
/
progresscircle.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* Inspiration for this project found at:
* https://markus.oberlehner.net/blog/pure-css-animated-svg-circle-chart
* 1. The `reverse` animation direction plays the animation backwards
* which makes it start at the stroke offset 100 which means displaying
* no stroke at all and animating it to the value defined in the SVG
* via the inline `stroke-dashoffset` attribute.
* 2. Rotate by -90 degree to make the starting point of the
* stroke the top of the circle.
* 3. Using CSS transforms on SVG elements is not supported by Internet Explorer
* and Edge, use the transform attribute directly on the SVG element as a
* . workaround.
*/
.circle-chart {
width: 200px;
height: 200px;
}
.circle-chart__circle {
stroke: #00acc1;
stroke-width: 2;
stroke-linecap: square;
fill: none;
animation: circle-chart-fill 2s reverse; /* 1 */
transform: rotate(-90deg); /* 2, 3 */
transform-origin: center; /* 4 */
}
/**
* 1. Rotate by -90 degree to make the starting point of the
* stroke the top of the circle.
* 2. Scaling mirrors the circle to make the stroke move right
* to mark a positive chart value.
* 3. Using CSS transforms on SVG elements is not supported by Internet Explorer
* and Edge, use the transform attribute directly on the SVG element as a
* . workaround.
*/
.circle-chart__circle--negative {
transform: rotate(-90deg) scale(1,-1); /* 1, 2, 3 */
}
.circle-chart__background {
stroke: #efefef;
stroke-width: 2;
fill: none;
}
.circle-chart__info {
animation: circle-chart-appear 2s forwards;
opacity: 0;
transform: translateY(0.3em);
}
.circle-chart__percent {
alignment-baseline: central;
text-anchor: middle;
font-size: 8px;
}
.circle-chart__subline {
alignment-baseline: central;
text-anchor: middle;
font-size: 3px;
}
.success-stroke {
stroke: #a60663;
}
.warning-stroke {
stroke: #ffbb33;
}
.danger-stroke {
stroke: #ff4444;
}
@keyframes circle-chart-fill {
to { stroke-dasharray: 0 100; }
}
@keyframes circle-chart-appear {
to {
opacity: 1;
transform: translateY(0);
}
}