Skip to content

Commit 3c1018d

Browse files
committed
fix svg example
1 parent daa2242 commit 3c1018d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

examples/svg.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
var sin = Math.sin(angle)
1010
var tx = x * cos - y * sin + 100
1111
var ty = x * sin + y * cos + 100
12+
13+
if (ty < 0) debugger
1214
return {
1315
x: tx,
1416
y: ty
@@ -26,13 +28,18 @@
2628
{ label: 'F', value: 100 }
2729
],
2830

29-
get points() {
30-
const total = this.stats.length
31-
return this.stats.map((stat, i) => valueToPoint(stat.value, i, total))
31+
get pointsString() {
32+
return this.getPoints()
33+
.map(({ x, y }) => `${x},${y}`)
34+
.join(' ')
3235
},
3336

34-
get pointsString() {
35-
return this.points.map(({ x, y }) => `${x},${y}`).join(' ')
37+
getPoints(offset = 0) {
38+
const total = this.stats.length
39+
return this.stats.map((stat, i) => ({
40+
...valueToPoint(+stat.value + offset, i, total),
41+
label: stat.label
42+
}))
3643
},
3744

3845
add(e) {
@@ -60,7 +67,7 @@
6067
<g>
6168
<polygon :points="pointsString"></polygon>
6269
<circle cx="100" cy="100" r="80"></circle>
63-
<text v-for="{ x, y, label } in points" :x="x" :y="y">{{ label }}</text>
70+
<text v-for="{ x, y, label } in getPoints(10)" :x="x" :y="y">{{ label }}</text>
6471
</g>
6572
</svg>
6673
<!-- controls -->

0 commit comments

Comments
 (0)