From d9974362e406611b86a5a47b2c9f1771fb2a2719 Mon Sep 17 00:00:00 2001 From: Nick White Date: Wed, 23 Oct 2019 13:23:20 +0100 Subject: Manually calculate yticks, so they fall on reasonable numbers --- graph.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/graph.go b/graph.go index bcdf2d8..44e650b 100644 --- a/graph.go +++ b/graph.go @@ -17,6 +17,7 @@ const maxticks = 40 const goodCutoff = 70 const mediumCutoff = 65 const badCutoff = 60 +const yticknum = 40 type Conf struct { Path, Code string @@ -82,6 +83,7 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error { // Create main xvalues, yvalues ticks var xvalues, yvalues []float64 var ticks []chart.Tick + var yticks []chart.Tick tickevery := len(graphconf) / maxticks if tickevery < 1 { tickevery = 1 @@ -96,6 +98,11 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error { // Make last tick the final page final := graphconf[len(graphconf)-1] ticks[len(ticks)-1] = chart.Tick{final.Pgnum, fmt.Sprintf("%.0f", final.Pgnum)} + for i := 1; i <= yticknum; i++ { + n := float64(i * 100) / yticknum + yticks = append(yticks, chart.Tick{n, fmt.Sprintf("%.1f", n)}) + } + mainSeries := chart.ContinuousSeries{ XValues: xvalues, YValues: yvalues, @@ -162,6 +169,7 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error { Min: 0.0, Max: 100.0, }, + Ticks: yticks, }, Series: []chart.Series{ mainSeries, -- cgit v1.2.1-24-ge1ad