Skip to content

Commit

Permalink
Charts: add new Pie Chart
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiy committed May 5, 2021
1 parent 5b4d0d6 commit 90ecdf8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/charts/_pie.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,44 @@
@include circle();

tr {
@include visually-hidden();
th {
@include visually-hidden();
}

td {
display: flex;
justify-content: center;
border-radius: 50%;

@include position-fullwidth();

background: conic-gradient(
transparent 0 calc( 1turn * var( --start ) ),
var( --c, transparent ) calc( 1turn * var( --start, 0 ) ) calc( 1turn * var( --end ) ),
transparent calc( 1turn * var( --end ) ) 1turn
);

&::before{
content: "";
@include position-fullwidth();
}

&::after {
content: "";
width: 100%;
}

.data {
display: flex;
justify-content: center;
border-radius: 50%;

@include position-fullwidth();

transform: rotate( calc( 0.5turn * var( --start, 0 ) + 0.5turn * var( --end, 0 ) ) );
}
}

}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
&.line tbody tr td:nth-of-type(#{ $total-colors }n + #{ $i })::before {
background: var(--color, var(--color-#{ $i }));
}

&.pie tbody tr:nth-of-type(#{ $total-colors }n + #{ $i }) td,
&.pie.multiple tbody tr td:nth-of-type(#{ $total-colors }n + #{ $i }) {
--c: var(--color, var(--color-#{ $i }, transparent) );
}
}

}
10 changes: 10 additions & 0 deletions src/general/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@
border-radius: 50%;
background-color: var(--chart-bg-color);
}

@mixin position-fullwidth {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}

0 comments on commit 90ecdf8

Please sign in to comment.