Skip to content

Commit 90ecdf8

Browse files
committed
Charts: add new Pie Chart
1 parent 5b4d0d6 commit 90ecdf8

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

src/charts/_pie.scss

+38-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,44 @@
1010
@include circle();
1111

1212
tr {
13-
@include visually-hidden();
13+
th {
14+
@include visually-hidden();
15+
}
16+
17+
td {
18+
display: flex;
19+
justify-content: center;
20+
border-radius: 50%;
21+
22+
@include position-fullwidth();
23+
24+
background: conic-gradient(
25+
transparent 0 calc( 1turn * var( --start ) ),
26+
var( --c, transparent ) calc( 1turn * var( --start, 0 ) ) calc( 1turn * var( --end ) ),
27+
transparent calc( 1turn * var( --end ) ) 1turn
28+
);
29+
30+
&::before{
31+
content: "";
32+
@include position-fullwidth();
33+
}
34+
35+
&::after {
36+
content: "";
37+
width: 100%;
38+
}
39+
40+
.data {
41+
display: flex;
42+
justify-content: center;
43+
border-radius: 50%;
44+
45+
@include position-fullwidth();
46+
47+
transform: rotate( calc( 0.5turn * var( --start, 0 ) + 0.5turn * var( --end, 0 ) ) );
48+
}
49+
}
50+
1451
}
1552
}
1653
}

src/components/_colors.scss

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
&.line tbody tr td:nth-of-type(#{ $total-colors }n + #{ $i })::before {
1313
background: var(--color, var(--color-#{ $i }));
1414
}
15+
16+
&.pie tbody tr:nth-of-type(#{ $total-colors }n + #{ $i }) td,
17+
&.pie.multiple tbody tr td:nth-of-type(#{ $total-colors }n + #{ $i }) {
18+
--c: var(--color, var(--color-#{ $i }, transparent) );
19+
}
1520
}
1621

1722
}

src/general/_mixins.scss

+10
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@
2323
border-radius: 50%;
2424
background-color: var(--chart-bg-color);
2525
}
26+
27+
@mixin position-fullwidth {
28+
position: absolute;
29+
top: 0;
30+
right: 0;
31+
bottom: 0;
32+
left: 0;
33+
width: 100%;
34+
height: 100%;
35+
}

0 commit comments

Comments
 (0)