Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
091b5e7
Merge remote-tracking branch 'origin/feat' into doc
setaman Mar 20, 2020
65b9d9e
Merge remote-tracking branch 'origin/doc' into doc
setaman Mar 21, 2020
86c4185
Merge remote-tracking branch 'origin/feat' into unit-tests
setaman Mar 21, 2020
c28fc3e
test: prepare tests for v1.0.0
setaman Mar 21, 2020
b950b78
fix: remove transition from container
setaman Mar 21, 2020
055d6e0
test: remove transition test from container
setaman Mar 21, 2020
33d7de2
test: remove rotation test from container
setaman Mar 21, 2020
f66c1a6
test: fix #thickness and #emptyThikness tests
setaman Mar 21, 2020
068f3cf
fix: empty circle thickness specification
setaman Mar 21, 2020
212bec8
test: fix #half tests
setaman Mar 21, 2020
2a68e5c
test: fix #animation.duration and #animation.delay tests
setaman Mar 21, 2020
5dd47e8
fix: #animation parser
setaman Mar 21, 2020
c52c1c6
fix: counter duration
setaman Mar 21, 2020
1f5af5c
test: fix #animation.type tests
setaman Mar 21, 2020
83f4296
test: reduce #lineMode test code redundancies
setaman Apr 2, 2020
86da747
test: add #dash test
setaman Apr 3, 2020
046def6
fix: parse dash count and spacing to numbers
setaman Apr 3, 2020
63d86ea
fix: remove code redundancies
setaman Apr 3, 2020
57dcdb1
fix: count-up delay and duration
setaman Apr 3, 2020
c43d3fb
test: cleanup #progress and #legendValue tests
setaman Apr 3, 2020
3e79e08
test: add more #noData test
setaman Apr 3, 2020
fee21ab
test: add #loading test for circle component
setaman Apr 3, 2020
d1dab50
test: fix and refactor color tests
setaman Apr 11, 2020
4211941
refactor: colors interface validation
setaman Apr 11, 2020
e525851
test: refactor colors tests
setaman Apr 11, 2020
0516cb1
fix: apply .default animation class by default
setaman Apr 11, 2020
169fe46
test: refactor #animation tests
setaman Apr 11, 2020
ade482e
test: fix #lineMode tests
setaman Apr 11, 2020
0862ef1
test: fix #line tests
setaman Apr 11, 2020
bddccd1
test: refactor line tests
setaman Apr 11, 2020
f33fb95
test: add #lineMode parser test
setaman Apr 11, 2020
6adfe26
fix: #lineMode prop validation
setaman Apr 11, 2020
7da1ef5
fix: parse #animation values to numbers
setaman Apr 11, 2020
717e86f
test: refactor #half tests
setaman Apr 11, 2020
d396c66
test: test #half circle SVG rendering
setaman Apr 11, 2020
354bf57
test: add #determinate tests
setaman Apr 11, 2020
4a65323
test: add #angle tests
setaman Apr 16, 2020
8d2af12
test: refactor container tests
setaman Apr 16, 2020
1ef8020
test: add props merging/overriding test for #data
setaman Apr 19, 2020
23423c1
test: add circles radius test for #data
setaman Apr 19, 2020
c6199c2
fix: multiple circles radius calculation
setaman Apr 19, 2020
c4a1087
test: add randomized #data tests to cover more cases
setaman Apr 19, 2020
02edc9f
fix: correctly fallback to global #gap and #thickness values on multi…
setaman Apr 19, 2020
c73119d
fix: add simplified interface to avoid unnecessary validation
setaman Apr 19, 2020
e44264d
fix: #animation prop validator
setaman Apr 19, 2020
2f2881b
fix: add #gap prop validator
setaman Apr 19, 2020
9c606ba
refac: rename CircleContainer.vue
setaman Apr 19, 2020
3eb5785
Merge pull request #48 from setaman/simplified-interface
setaman Apr 19, 2020
e048832
fix: add default props values to simplified interface
setaman Apr 19, 2020
0311fde
test: fix #animation tests
setaman Apr 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ module.exports = {
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
"no-underscore-dangle": "off",
"no-plusplus": "off",
"max-len": [2, 120, 8]
"max-len": [2, 120, 8],
"no-restricted-syntax": "off",
"guard-for-in": "off"
},
parserOptions: {
parser: "babel-eslint"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-ellipse-progress",
"version": "1.0.0-beta.0",
"version": "1.0.0-beta.14",
"private": false,
"description": "A Vue.js component to create beautiful animated circular progress bars",
"main": "./dist/vue-ellipse-progress.umd.min.js",
Expand Down
124 changes: 60 additions & 64 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,41 @@
No DATA
<input id="nodata" type="checkbox" v-model="noData" />
</label>
<label for="animation">
Animation
<input v-model="animation" id="animation" />
</label>
<label for="line">
line
<input v-model="line" id="line" />
</label>
<label for="determinate">
Determinate
<input id="determinate" type="checkbox" v-model="circles[0].determinate" />
<input id="determinate2" type="checkbox" v-model="determinate" />
</label>
</div>
<div>
<!--<div>
<input type="checkbox" v-model="circles[0].loading" />
<input type="checkbox" v-model="circles[1].loading" />
<input type="checkbox" v-model="circles[2].loading" />
<input type="checkbox" v-model="circles[3].loading" />
</div>
</div>-->
<vue-ellipse-progress
:gap="30"
:gap="5"
color-fill="rgba(17,34,51,0.0)"
half
:data="circles"
:size="700"
:thickness="40"
:progress="progress"
:data="circlesTest"
:size="400"
:thickness="5"
empty-color="rgba(17,34,51,0.66)"
animation="rs 1000 0"
:legend-value="10.45"
:loading="loading"
:no-data="noData"
>
<span slot="legend-value">/hui</span>
<p slot="legend-caption" class="ma-0">This is caption slot</p>
</vue-ellipse-progress>
<vue-ellipse-progress

<!--<vue-ellipse-progress
id="timer-example"
:progress="parseFloat(timerProgress)"
:determinate="determinate"
Expand All @@ -66,29 +71,27 @@
:noData="noData"
animation="loop 700 300"
>
</vue-ellipse-progress>-->
<vue-ellipse-progress
:progress="50"
:animation="animation"
:loading="loading"
emptyColor="red"
line-mode="out"
dash="strict 60 0.8"
:no-data="noData"
:line="line"
>
</vue-ellipse-progress>
<vue-ellipse-progress :progress="67" line-mode="out 20" dash="strict 10 0.98"> </vue-ellipse-progress>
<!--<vue-ellipse-progress
<vue-ellipse-progress
id="half-example"
:progress="parseFloat(timerProgress)"
:color="color"
:loading="loading"
:emptyColor="emptyColor"
emptyColorFill=""
thickness="10"
emptyThickness="10"
:size="size"
line="round"
:lineMode="{ mode: 'in', offset: 10 }"
:legend="true"
:legendValue="sec"
legendClass="legend-custom-style"
:noData="noData"
:animation="{ type: 'reverse', duration: 700, delay: 300 }"
fontSize="4rem"
fontColor="white"
angle="-90"
:progress="88"
:size="200"
line-mode="in-over 10"
half
:thickness="20"
:empty-thickness="10"
:colorFill="emptyColorFill"
>
<span slot="legend-value"></span>
</vue-ellipse-progress>
Expand All @@ -99,7 +102,7 @@
<input v-model="tasks_done" max="200" min="0" type="number" id="tasks" />
<button @click="updateTasksDone">Update Tasks</button>
</div>
<vue-ellipse-progress
<!--<vue-ellipse-progress
:progress="parseFloat(tasksDonePercent)"
:color="color"
:emptyColor="emptyColor"
Expand Down Expand Up @@ -140,42 +143,17 @@
</div>
</template>
<script>
const randomNumberInRange = (min = 0, max = 10) => Math.floor(Math.random() * (max - min + 1)) + min;

export default {
name: "app",
components: {},
data: () => ({
line: "round",
circles: [
{
progress: 0,
thickness: 40,
animation: "rs 2000 2000",
loading: false,
half: true
},
{
progress: 55,
thickness: 40,
color: "blue",
// angle: "-90",
loading: false,
animation: "bounce 2000 400"
},
{
progress: 35,
thickness: 40,
color: "red",
// angle: "155",
loading: false,
animation: "loop 2000 600"
},
{
progress: 15,
thickness: 40,
color: "yellow",
// angle: "165",
loading: false,
animation: "reverse 2000 800"
}
{ progress: 25, color: "red", gap: 25, thickness: 5 },
{ progress: 35, color: "blue", gap: 10, thickness: 5 },
{ progress: 55, color: "green" }
],
determinate: false,
loading: false,
Expand Down Expand Up @@ -229,11 +207,29 @@ export default {
}
],
radial: true
}
},
animation: "rs 200 5000"
}),
computed: {
tasksDonePercent() {
return (this.tasks_done * 100) / 200;
},
circlesTest() {
const data = [];
// generate random test data
for (let n = 0; n < 6; n++) {
data.push({
progress: 25,
gap: randomNumberInRange(),
thickness: randomNumberInRange()
});
}
// some special cases
data.push({ progress: 50, color: "red", thickness: 5 });
data.push({ progress: 50, gap: 5 });
data.push({ progress: 50, gap: 0 });
data.push({ progress: 50 });
return data;
}
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,46 @@
<gradient v-if="isEmptyColorGradient" :color="emptyColor" type="empty" :id="_uid" />
<gradient v-if="isEmptyColorFillGradient" :color="emptyColorFill" type="empty-fill" :id="_uid" />
</defs>
<component :is="circleType" v-bind="$props" :multiple="multiple" :id="_uid" :index="index" />
<component :is="circleType" v-bind="$props" :id="_uid" />
</g>
</template>

<script>
import Gradient from "../Gradient.vue";
import HalfCircleProgress from "./HalfCircleProgress.vue";
import CircleProgress from "./CircleProgress.vue";
import { getValueIfDefined } from "../../utils";
import { getNumberIfValid } from "../../utils";
import { simplifiedProps } from "../interface";

export default {
name: "EpCircleContainer",
components: { CircleProgress, HalfCircleProgress, Gradient },
props: {
...CircleProgress.mixins[0].props
...simplifiedProps,
index: {
type: Number,
required: true
},
multiple: {
type: Boolean,
required: true
},
globalThickness: {
type: [Number, String],
required: false,
default: "5%"
},
globalGap: {
type: Number,
required: false
}
},
computed: {
circleType() {
return this.half ? "half-circle-progress" : "circle-progress";
},
startAngle() {
return getValueIfDefined(this.angle) || -90;
return getNumberIfValid(this.angle) || -90;
},
isColorGradient() {
return Array.isArray(this.color.colors);
Expand Down
3 changes: 1 addition & 2 deletions src/components/Circle/CircleProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:fill="computedEmptyColorFill"
:style="{ transition: animationDuration }"
:class="{ 'ep_circle--nodata': !dataIsAvailable }"
:stroke-width="emptyThickness"
:stroke-width="computedEmptyThickness"
>
</circle>
<fade-in-transition>
Expand Down Expand Up @@ -58,7 +58,6 @@ export default {
components: { FadeInTransition },
mixins: [CircleMixin],
computed: {
// only component specific props here, another props comes from the circleMixin
progressOffset() {
const offset = this.circumference - (this.computedProgress / 100) * this.circumference;
if (offset <= 0) {
Expand Down
34 changes: 26 additions & 8 deletions src/components/Circle/circleMixin.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import { isValidNumber } from "../../utils";
import { animationParser, dashParser, lineModeParser } from "../optionsParser";
import interfaceDefinition from "../interface";
import { simplifiedProps } from "../interface";

const wait = (ms = 400) => new Promise(resolve => setTimeout(() => resolve(), ms));

export default {
name: "CircleMixin",
props: {
...interfaceDefinition,
...simplifiedProps,
multiple: {
type: Boolean,
required: true
},
id: {
type: Number,
required: false
required: true
},
index: {
type: Number,
required: true
},
globalThickness: {
type: [Number, String],
required: false,
default: "5%"
},
globalGap: {
type: Number,
required: false
}
},
data() {
Expand All @@ -35,7 +44,7 @@ export default {
const { offset } = this.parsedLineMode;

if (this.multiple) {
return this.normalLineModeRadius - this.previousCirclesThickness;
return this.baseRadius - this.previousCirclesThickness;
}

switch (this.parsedLineMode.mode) {
Expand All @@ -61,7 +70,7 @@ export default {
const { offset } = this.parsedLineMode;

if (this.multiple) {
return this.normalLineModeRadius - this.previousCirclesThickness;
return this.baseRadius - this.previousCirclesThickness;
}

switch (this.parsedLineMode.mode) {
Expand Down Expand Up @@ -112,7 +121,7 @@ export default {
animationClass() {
return [
`animation__${
!this.loading && this.dataIsAvailable && this.isInitialized ? this.parsedAnimation.type : "none"
!this.loading && this.dataIsAvailable && this.isInitialized ? this.parsedAnimation.type : "default"
}`,
`${this.loading ? "animation__loading" : ""}`
];
Expand Down Expand Up @@ -145,6 +154,9 @@ export default {
computedThickness() {
return this.calculateThickness(this.thickness.toString());
},
computedGlobalThickness() {
return this.calculateThickness(this.globalThickness.toString());
},
computedEmptyThickness() {
return this.calculateThickness(this.emptyThickness.toString());
},
Expand All @@ -166,10 +178,16 @@ export default {
},
previousCirclesThickness() {
if (this.index === 0) return 0;
return this.data
const currentCircleGap = isValidNumber(this.data[this.index].gap) ? this.data[this.index].gap : this.gap;
const previousCirclesGap = this.data
.filter((data, i) => i < this.index)
.map(data => (data.thickness || this.thickness) + (data.gap || this.gap))
.map(data => {
const thickness = isValidNumber(data.thickness) ? data.thickness : this.computedGlobalThickness;
const gap = isValidNumber(data.gap) ? data.gap : this.globalGap;
return thickness + gap;
})
.reduce((acc, current) => acc + current);
return previousCirclesGap + currentCircleGap;
},
styles() {
return {
Expand Down
Loading