From 5362b590d6d2772fa43f4b6513872851cbd2b7bd Mon Sep 17 00:00:00 2001 From: Juan Massuelles Date: Fri, 7 Jul 2023 17:42:39 +0200 Subject: [PATCH] [HTML/CSS] pure css pie charts using sass variables --- pies/_pie-charts.scss | 55 +++++++++++++++++++++++++++++++++---------------- pies/pie-charts.css | 35 +++++++++++++++++-------------- pies/pie-charts.css.map | 4 ++-- 3 files changed, 58 insertions(+), 36 deletions(-) diff --git a/pies/_pie-charts.scss b/pies/_pie-charts.scss index 28d8242..e17763f 100644 --- a/pies/_pie-charts.scss +++ b/pies/_pie-charts.scss @@ -1,33 +1,52 @@ +$pie-size:300px; +$pie-bg:#3434AF; +$red:#ed3457; +$green:#248991; +$orange:#ed8724; +$line-color:#cecece; +$border-width:5px; +$segment-border-width:1px; + :root{ - --pie-size:300; - --pie-bg:#3434AF; - --red:#ed3457; - --green:#248991; - --orange:#ed8724; - --line-color:#cecece; + font-family: sans-serif; } .pie,.target { border-radius: 100%; position: relative; } + .pie { - height: calc( var(--pie-size,200) * 1px ); - width: calc( var(--pie-size,200) * 1px ); - background-color:var(--pie-bg,black); - top:5px; - left:5px; + height: $pie-size; + width: $pie-size; + background-color:$pie-bg; + top:$border-width; + left:$border-width; + &-segment { + border: dotted $segment-border-width $line-color; + position: absolute; + height: 100%; + width:100%; + } } + .target { - height: calc( (var(--pie-size,200) + 10) * 1px ); - width: calc( (var(--pie-size,200) + 10) * 1px ); - background-color:var(--line-color,grey); + height: ($pie-size + $border-width * 2); + width: ($pie-size + $border-width * 2); + background-color:$line-color; } .references { position:fixed; - bottom:0; - left:0; - right:0; - background-color:var(--line-color); + bottom:5px; + right:5px; + border-radius:5px; + padding:10px; + background-color:lightblue; + a { + &[href],&:link,&:hover,&:focus,&:active { + color:darkblue; + } + } } + diff --git a/pies/pie-charts.css b/pies/pie-charts.css index dea9315..d4f9c8e 100644 --- a/pies/pie-charts.css +++ b/pies/pie-charts.css @@ -1,32 +1,35 @@ :root { - --pie-size:300; - --pie-bg:#3434AF; - --red:#ed3457; - --green:#248991; - --orange:#ed8724; - --line-color:#cecece; } + font-family: sans-serif; } .pie, .target { border-radius: 100%; position: relative; } .pie { - height: calc( var(--pie-size,200) * 1px ); - width: calc( var(--pie-size,200) * 1px ); - background-color: var(--pie-bg, black); + height: 300px; + width: 300px; + background-color: #3434AF; top: 5px; left: 5px; } + .pie-segment { + border: dotted 1px #cecece; + position: absolute; + height: 100%; + width: 100%; } .target { - height: calc( (var(--pie-size,200) + 10) * 1px ); - width: calc( (var(--pie-size,200) + 10) * 1px ); - background-color: var(--line-color, grey); } + height: 310px; + width: 310px; + background-color: #cecece; } .references { position: fixed; - bottom: 0; - left: 0; - right: 0; - background-color: var(--line-color); } + bottom: 5px; + right: 5px; + border-radius: 5px; + padding: 10px; + background-color: lightblue; } + .references a[href], .references a:link, .references a:hover, .references a:focus, .references a:active { + color: darkblue; } /*# sourceMappingURL=pie-charts.css.map */ diff --git a/pies/pie-charts.css.map b/pies/pie-charts.css.map index 80779cf..468c661 100644 --- a/pies/pie-charts.css.map +++ b/pies/pie-charts.css.map @@ -1,7 +1,7 @@ { "version": 3, -"mappings": "AAAA,KAAK;EACH,UAAU,CAAC,GAAG;EACd,QAAQ,CAAC,OAAO;EAChB,KAAK,CAAC,OAAO;EACb,OAAO,CAAC,OAAO;EACf,QAAQ,CAAC,OAAO;EAChB,YAAY,CAAC,OAAO;;AAGtB,aAAa;EACX,aAAa,EAAE,IAAI;EACnB,QAAQ,EAAE,QAAQ;;AAEpB,IAAK;EACH,MAAM,EAAE,iCAAiC;EACzC,KAAK,EAAG,iCAAiC;EACzC,gBAAgB,EAAC,oBAAmB;EACpC,GAAG,EAAC,GAAG;EACP,IAAI,EAAC,GAAG;;AAEV,OAAQ;EACN,MAAM,EAAE,wCAAwC;EAChD,KAAK,EAAG,wCAAwC;EAChD,gBAAgB,EAAC,uBAAsB;;AAGzC,WAAY;EACV,QAAQ,EAAC,KAAK;EACd,MAAM,EAAC,CAAC;EACR,IA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