summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-10-23 13:07:02 +0100
committerNick White <git@njw.name>2019-10-23 13:07:02 +0100
commit6f4f10e91cb083bfd0a64e15c86197da6461aa2d (patch)
tree70b97f4ab07430ebf7aa07144ea1856345d5e51f
parent9840edb21ab1bca093001d81c510910bb00c73d4 (diff)
Add more annotations to graph; anything outside of the 80% "normal" band gets an annotation now, and that band is labelled
-rw-r--r--graph.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/graph.go b/graph.go
index d42baee..bcdf2d8 100644
--- a/graph.go
+++ b/graph.go
@@ -79,9 +79,8 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error {
sort.Slice(graphconf, func(i, j int) bool { return graphconf[i].Pgnum < graphconf[j].Pgnum })
- // Create main xvalues and yvalues, annotations and ticks
+ // Create main xvalues, yvalues ticks
var xvalues, yvalues []float64
- var annotations []chart.Value2
var ticks []chart.Tick
tickevery := len(graphconf) / maxticks
if tickevery < 1 {
@@ -90,14 +89,11 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error {
for i, c := range graphconf {
xvalues = append(xvalues, c.Pgnum)
yvalues = append(yvalues, c.Conf)
- if c.Conf < goodCutoff {
- annotations = append(annotations, chart.Value2{Label: fmt.Sprintf("%.0f", c.Pgnum), XValue: c.Pgnum, YValue: c.Conf})
- }
if i%tickevery == 0 {
ticks = append(ticks, chart.Tick{c.Pgnum, fmt.Sprintf("%.0f", c.Pgnum)})
}
}
- // make last tick the final page
+ // Make last tick the final page
final := graphconf[len(graphconf)-1]
ticks[len(ticks)-1] = chart.Tick{final.Pgnum, fmt.Sprintf("%.0f", final.Pgnum)}
mainSeries := chart.ContinuousSeries{
@@ -127,7 +123,7 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error {
YValues: yvalues,
}
yvalues = []float64{}
- for _ = range graphconf {
+ for range graphconf {
yvalues = append(yvalues, highconf)
}
maxSeries := &chart.ContinuousSeries{
@@ -139,6 +135,16 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error {
YValues: yvalues,
}
+ // Create annotations
+ var annotations []chart.Value2
+ for _, c := range graphconf {
+ if c.Conf > highconf || c.Conf < lowconf {
+ annotations = append(annotations, chart.Value2{Label: fmt.Sprintf("%.0f", c.Pgnum), XValue: c.Pgnum, YValue: c.Conf})
+ }
+ }
+ annotations = append(annotations, chart.Value2{Label: fmt.Sprintf("%.0f", lowconf), XValue: xvalues[len(xvalues)-1], YValue: lowconf})
+ annotations = append(annotations, chart.Value2{Label: fmt.Sprintf("%.0f", highconf), XValue: xvalues[len(xvalues)-1], YValue: highconf})
+
graph := chart.Chart{
Title: bookname,
Width: 3840,