summaryrefslogtreecommitdiff
path: root/bookpipeline
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-08-28 22:40:02 +0100
committerNick White <git@njw.name>2019-08-28 22:40:02 +0100
commitbd557cbeb752c6296f3a74cc2c7aea5c13bb55fa (patch)
treec7dc536691f2cddbba6aa8c6b0b3e639ecbb8e25 /bookpipeline
parent8e75a646d1f8bb64379a67b1160d681768f3ec5f (diff)
Add medium and bad lines to graphs
Diffstat (limited to 'bookpipeline')
-rw-r--r--bookpipeline/graph.go45
1 files changed, 28 insertions, 17 deletions
diff --git a/bookpipeline/graph.go b/bookpipeline/graph.go
index 4386218..67deb33 100644
--- a/bookpipeline/graph.go
+++ b/bookpipeline/graph.go
@@ -9,10 +9,13 @@ import (
"strings"
"github.com/wcharczuk/go-chart"
+ "github.com/wcharczuk/go-chart/drawing"
)
const maxticks = 20
-const cutoff = 70
+const goodCutoff = 70
+const mediumCutoff = 65
+const badCutoff = 60
type Conf struct {
Path, Code string
@@ -23,6 +26,22 @@ type GraphConf struct {
Pgnum, Conf float64
}
+func createLine(xvalues []float64, y float64, c drawing.Color) chart.ContinuousSeries {
+ var yvalues []float64
+ for _ = range xvalues {
+ yvalues = append(yvalues, y)
+ }
+ return chart.ContinuousSeries{
+ XValues: xvalues,
+ YValues: yvalues,
+ Style: chart.Style{
+ Show: true,
+ StrokeColor: c,
+ StrokeDashArray: []float64{10.0, 5.0},
+ },
+ }
+}
+
func Graph(confs map[string]*Conf, bookname string, w io.Writer) error {
// Organise confs to sort them by page
var graphconf []GraphConf
@@ -54,7 +73,7 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error {
i = i + 1
xvalues = append(xvalues, c.Pgnum)
yvalues = append(yvalues, c.Conf)
- if c.Conf < cutoff {
+ if c.Conf < goodCutoff {
annotations = append(annotations, chart.Value2{Label: fmt.Sprintf("%.0f", c.Pgnum), XValue: c.Pgnum, YValue: c.Conf})
}
if tickevery % i == 0 {
@@ -66,20 +85,10 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error {
YValues: yvalues,
}
- // Create 70% line
- yvalues = []float64{}
- for _ = range xvalues {
- yvalues = append(yvalues, cutoff)
- }
- cutoffSeries := chart.ContinuousSeries{
- XValues: xvalues,
- YValues: yvalues,
- Style: chart.Style{
- Show: true,
- StrokeColor: chart.ColorAlternateGreen,
- StrokeDashArray: []float64{10.0, 5.0},
- },
- }
+ // Create lines
+ goodCutoffSeries := createLine(xvalues, goodCutoff, chart.ColorAlternateGreen)
+ mediumCutoffSeries := createLine(xvalues, mediumCutoff, chart.ColorOrange)
+ badCutoffSeries := createLine(xvalues, badCutoff, chart.ColorRed)
// Create lines marking top and bottom 10% confidence
sort.Slice(graphconf, func(i, j int) bool { return graphconf[i].Conf < graphconf[j].Conf })
@@ -139,7 +148,9 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error {
mainSeries,
minSeries,
maxSeries,
- cutoffSeries,
+ goodCutoffSeries,
+ mediumCutoffSeries,
+ badCutoffSeries,
chart.AnnotationSeries{
Annotations: annotations,
},