Skip to content

Commit 06c96f6

Browse files
committed
refac: fill circles radius calculation
1 parent 09703a2 commit 06c96f6

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

src/App.vue

+3-4
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@
4040
<div style="border: 1px solid red; display: inline-block">
4141
<ve-progress
4242
:size="600"
43-
half
4443
:angle="0"
45-
line-position="out 70"
44+
line-position="out 26"
4645
empty-line-position="out 20"
4746
empty-color-fill="red"
48-
color-fill="green"
49-
empty-color="transparent"
47+
color-fill="#273266"
48+
empty-color="blue"
5049
:progress="progress"
5150
:no-data="noData"
5251
>

src/components/Circle/circleMixin.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { emptyRadius, radius } from "@/components/Circle/radiusCalculation";
1+
import { emptyRadius, fillRadius, radius } from "@/components/Circle/radiusCalculation";
22
import { isValidNumber } from "../../utils";
33

44
const wait = (ms = 400) => new Promise((resolve) => setTimeout(() => resolve(), ms));
@@ -33,23 +33,13 @@ export default {
3333
return radius(this.options);
3434
},
3535
fillRadius() {
36-
const { offset, position } = this.options.linePosition;
37-
if (position === "center") {
38-
return this.radius;
39-
}
40-
return position === "out" ? this.radius - offset - this.thickness / 2 : this.radius + this.thickness / 2;
36+
return fillRadius(this.options.linePosition, this.thickness, this.radius);
4137
},
4238
emptyRadius() {
4339
return emptyRadius(this.options);
4440
},
4541
emptyFillRadius() {
46-
const { offset, position } = this.options.emptyLinePosition;
47-
if (position === "center") {
48-
return this.emptyRadius;
49-
}
50-
return position === "out"
51-
? this.emptyRadius - offset - this.emptyThickness / 2
52-
: this.emptyRadius + this.emptyThickness / 2;
42+
return fillRadius(this.options.emptyLinePosition, this.emptyThickness, this.emptyRadius);
5343
},
5444

5545
dataIsAvailable() {

src/components/Circle/radiusCalculation.js

+8
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,11 @@ export const emptyRadius = (options) => {
105105
const modeHandler = modes[options.lineMode.mode];
106106
return modeHandler ? modeHandler() : emptyBaseRadius(options);
107107
};
108+
109+
export const fillRadius = (linePosition, thickness, lineCircleRadius) => {
110+
const { position, offset } = linePosition;
111+
if (position === "center") {
112+
return lineCircleRadius;
113+
}
114+
return position === "out" ? lineCircleRadius - offset - thickness / 2 : lineCircleRadius + thickness / 2;
115+
};

0 commit comments

Comments
 (0)