summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-08-27 21:54:28 +0100
committerNick White <git@njw.name>2019-08-27 21:54:28 +0100
commit7d13974a4a79c4175869c2ef227d04617a8ea515 (patch)
tree770a560fbddc4e1f0efe52d0ee83b10116b69753
parent877a718fa68af1ecc67c0e34dce9c6edf31191fc (diff)
Print x axis ticks nicely
-rw-r--r--bookpipeline/main.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/bookpipeline/main.go b/bookpipeline/main.go
index c202bad..cb02f5e 100644
--- a/bookpipeline/main.go
+++ b/bookpipeline/main.go
@@ -232,12 +232,19 @@ func analyse(toanalyse chan string, up chan string, errc chan error, logger *log
sort.Slice(graphconf, func(i, j int) bool { return graphconf[i].pgnum < graphconf[j].pgnum })
var xvalues, yvalues []float64
var annotations []chart.Value2
+ var ticks []chart.Tick
+ i := 0
+ tickevery := len(graphconf) / 20
for _, c := range graphconf {
+ i = i + 1
xvalues = append(xvalues, c.pgnum)
yvalues = append(yvalues, c.conf)
if c.conf < 70 {
annotations = append(annotations, chart.Value2{Label: fmt.Sprintf("%.0f", c.pgnum), XValue: c.pgnum, YValue: c.conf})
}
+ if tickevery % i == 0 {
+ ticks = append(ticks, chart.Tick{c.pgnum, fmt.Sprintf("%.0f", c.pgnum)})
+ }
}
mainSeries := chart.ContinuousSeries{
XValues: xvalues,
@@ -277,9 +284,6 @@ func analyse(toanalyse chan string, up chan string, errc chan error, logger *log
InnerSeries: mostSeries,
}
- // TODO: annotate all values below 70%; see
- // https://github.com/wcharczuk/go-chart/blob/master/_examples/annotations/main.go
-
// TODO: add number of words series using yaxissecondary
graph := chart.Chart{
XAxis: chart.XAxis{
@@ -289,6 +293,7 @@ func analyse(toanalyse chan string, up chan string, errc chan error, logger *log
Range: &chart.ContinuousRange{
Min: 0.0,
},
+ Ticks: ticks,
},
YAxis: chart.YAxis{
Name: "Confidence",