forked from open-indy/Koa11y
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple-donut.vue, not hooked up yet
- Loading branch information
1 parent
2e70131
commit af9f8d9
Showing
2 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<div class="donut-size"> | ||
<div :class="[donut ? 'donut-graph' : 'pie-graph', 'pie-wrapper']"> | ||
<span class="label"> | ||
<span>{{ percent }}</span><span class="smaller">%</span> | ||
</span> | ||
<div class="pie" :style="{clip: pie}"> | ||
<div class="left-side half-circle" :style="{'transform': leftside}"></div> | ||
<div class="right-side half-circle" :style="{'transform': rightside}"></div> | ||
</div> | ||
<div class="shadow"></div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
module.exports = { | ||
props: { | ||
donut: { | ||
type: Boolean, | ||
required: false, | ||
default: true | ||
}, | ||
'percent': { | ||
type: Number, | ||
required: false, | ||
default: 0 | ||
} | ||
}, | ||
watch: { | ||
percent: function () { | ||
var forWholeNumber = Math.round(this.percent); | ||
var restrictUpperLimit = Math.min(forWholeNumber, 100); | ||
var restrictLowerLimit = Math.max(restrictUpperLimit, 0); | ||
this.percent = restrictLowerLimit; | ||
} | ||
}, | ||
computed: { | ||
'pie': function () { | ||
var pie = 'rect(0, 1em, 1em, 0.5em)'; | ||
if (Math.round(this.percent) > 50) { | ||
pie = 'rect(auto, auto, auto, auto)'; | ||
} | ||
return pie; | ||
}, | ||
'leftside': function () { | ||
var degrees = Math.round(360 * (this.percent / 100)); | ||
var rotation = 'rotate(' + degrees + 'deg)'; | ||
return rotation; | ||
}, | ||
'rightside': function () { | ||
var rotation = 'rotate(0deg)'; | ||
if (Math.round(this.percent) > 50) { | ||
rotation = 'rotate(180deg)'; | ||
} | ||
return rotation; | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters