Skip to content

Commit

Permalink
fix: Label position of the pie chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Heidrich authored and jentfoo committed Apr 9, 2024
1 parent 57c9f2d commit 8e0060f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pie_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewSector(cx int, cy int, radius float64, labelRadius float64, value float6
s.cy = cy
s.rx = radius
s.ry = radius
p := currentValue / totalValue
p := (currentValue + value/2) / totalValue
if p < 0.25 {
s.quadrant = 1
} else if p < 0.5 {
Expand All @@ -79,7 +79,7 @@ func NewSector(cx int, cy int, radius float64, labelRadius float64, value float6
} else {
s.quadrant = 2
}
s.start = chart.PercentToRadians(currentValue/totalValue) - math.Pi/2 // Bogenmaß
s.start = chart.PercentToRadians(currentValue/totalValue) - math.Pi/2
s.delta = chart.PercentToRadians(value / totalValue)
angle := s.start + s.delta/2
s.lineStartX = cx + int(radius*math.Cos(angle))
Expand Down
Loading

0 comments on commit 8e0060f

Please sign in to comment.