From eb8ebed83039100b10ad7f30059b4a7b5954950a Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 7 Jul 2017 02:53:19 +0200 Subject: [PATCH] HSL model for pie charts --- pages/statistics/statistics.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pages/statistics/statistics.go b/pages/statistics/statistics.go index 3bc4c9d3..8cc06f90 100644 --- a/pages/statistics/statistics.go +++ b/pages/statistics/statistics.go @@ -66,6 +66,8 @@ func Get(ctx *aero.Context) string { slices := []*utils.PieChartSlice{} current := 0.0 + hueOffset := 0.0 + hueScaling := 60.0 for _, item := range screenSizesSorted { percentage := float64(item.Value) / float64(len(analytics)) @@ -74,7 +76,7 @@ func Get(ctx *aero.Context) string { From: current, To: current + percentage, Title: fmt.Sprintf("%s (%d%%)", item.Key, int(percentage*100+0.5)), - Color: fmt.Sprintf("rgba(255, 64, 0, %.3f)", 0.8-current*0.8), + Color: fmt.Sprintf("hsl(%.1f, 75%%, 50%%)", current*hueScaling+hueOffset), }) current += percentage