mirror of
https://github.com/nkoehring/250kb-club.git
synced 2025-04-19 13:49:04 +02:00
a gauge
This commit is contained in:
parent
cfb09edbde
commit
de9d6d2b80
1 changed files with 44 additions and 0 deletions
44
src/components/Gauge.svelte
Normal file
44
src/components/Gauge.svelte
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<script>
|
||||||
|
const radius = 40
|
||||||
|
const dashes = 2 * Math.PI * radius
|
||||||
|
|
||||||
|
export let max = 100
|
||||||
|
export let value = 1
|
||||||
|
|
||||||
|
$: offset = dashes * value / max * -1
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="gauge-box">
|
||||||
|
<svg viewBox="0 0 100 100" class="gauge">
|
||||||
|
<circle class="dial" cx="50" cy="50" r={radius} />
|
||||||
|
<circle class="dial value" cx="50" cy="50" r={radius}
|
||||||
|
stroke-dasharray={dashes}
|
||||||
|
stroke-dashoffset={offset}
|
||||||
|
/>
|
||||||
|
<circle class="dial value2" cx="50" cy="50" r={radius}
|
||||||
|
stroke-dasharray={dashes}
|
||||||
|
stroke-dashoffset={offset*1.2}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.gauge-box {
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
margin-top: -10px;
|
||||||
|
}
|
||||||
|
.gauge {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
transform: rotate(-90deg);
|
||||||
|
}
|
||||||
|
.dial {
|
||||||
|
fill: none;
|
||||||
|
stroke: #333;
|
||||||
|
stroke-width: 4;
|
||||||
|
}
|
||||||
|
.value { stroke: green; }
|
||||||
|
.value2 { stroke: yellow; }
|
||||||
|
</style>
|
Loading…
Add table
Reference in a new issue