fix : 饼图D3 样式更改

This commit is contained in:
likexuan
2022-08-01 17:54:55 +08:00
parent 8d84ba6e54
commit d432b671a9

View File

@@ -230,6 +230,9 @@ export default {
if (Math.ceil(this.outerRadius / 8) < 30) {
height = Math.ceil(this.outerRadius / 8) * 3
}
if ((d.endAngle - d.startAngle) > 5) {
height += this.outerRadius
}
return y - height / 2
})
.attr('x', d => { // y轴居中减文字大小的一半
@@ -240,9 +243,9 @@ export default {
width = 0
} else {
if ((d.endAngle - d.startAngle) > 5) {
width = this.outerRadius
width = this.outerRadius * 2
}
width = this.outerRadius * (d.endAngle - d.startAngle) / 5
width = this.outerRadius * (d.endAngle - d.startAngle) / 3.14
width = width > this.outerRadius / 3 ? width : this.outerRadius / 3
}
return x - width / 2
@@ -258,13 +261,13 @@ export default {
if ((d.endAngle - d.startAngle) < 0.25) {
return 0
} else {
if ((d.endAngle - d.startAngle) > 3.14) {
return this.outerRadius
if ((d.endAngle - d.startAngle) > 5) {
return this.outerRadius * 2
}
let width = 0
showAngle += d.endAngle - d.startAngle
if (showAngle > 0.5) {
width = this.outerRadius * (d.endAngle - d.startAngle) / 5
if (showAngle > 0.75) {
width = this.outerRadius * (d.endAngle - d.startAngle) / 3.14
width = width > this.outerRadius / 3 ? width : this.outerRadius / 3
showAngle = 0
} else {
@@ -467,5 +470,5 @@ export default {
</script>
<style scoped>
</style>>
</style>