report card

This commit is contained in:
Will Charczuk 2016-08-07 10:51:06 -07:00
parent 63a26acadd
commit c19111629c
3 changed files with 284 additions and 1 deletions

View file

@ -1,6 +1,6 @@
go-chart go-chart
======== ========
[![Build Status](https://travis-ci.org/wcharczuk/go-chart.svg?branch=master)](https://travis-ci.org/wcharczuk/go-chart) [![Build Status](https://travis-ci.org/wcharczuk/go-chart.svg?branch=master)](https://travis-ci.org/wcharczuk/go-chart)[![Go Report Card](https://goreportcard.com/badge/github.com/wcharczuk/go-chart)](https://goreportcard.com/report/github.com/wcharczuk/go-chart)
Package `chart` is a very simple golang native charting library that supports timeseries and continuous Package `chart` is a very simple golang native charting library that supports timeseries and continuous
line charts. line charts.

View file

@ -0,0 +1,113 @@
package main
import (
"net/http"
"strings"
"time"
util "github.com/blendlabs/go-util"
"github.com/wcharczuk/go-chart"
)
func readData() ([]time.Time, []float64) {
var xvalues []time.Time
var yvalues []float64
util.ReadFileByLines("requests.csv", func(line string) {
parts := strings.Split(line, ",")
year := util.ParseInt(parts[0])
month := util.ParseInt(parts[1])
day := util.ParseInt(parts[2])
hour := util.ParseInt(parts[3])
elapsedMillis := util.ParseFloat64(parts[4])
xvalues = append(xvalues, time.Date(year, time.Month(month), day, hour, 0, 0, 0, time.UTC))
yvalues = append(yvalues, elapsedMillis)
})
return xvalues, yvalues
}
func drawChart(res http.ResponseWriter, req *http.Request) {
xvalues, yvalues := readData()
mainSeries := chart.TimeSeries{
Name: "Prod Request Timings",
Style: chart.Style{
Show: true,
StrokeColor: chart.ColorBlue,
FillColor: chart.ColorBlue.WithAlpha(100),
},
XValues: xvalues,
YValues: yvalues,
}
minSeries := &chart.MinSeries{
Style: chart.Style{
Show: true,
StrokeColor: chart.ColorAlternateGray,
StrokeDashArray: []float64{5.0, 5.0},
},
InnerSeries: mainSeries,
}
maxSeries := &chart.MaxSeries{
Style: chart.Style{
Show: true,
StrokeColor: chart.ColorAlternateGray,
StrokeDashArray: []float64{5.0, 5.0},
},
InnerSeries: mainSeries,
}
linreg := &chart.LinearRegressionSeries{
Name: "Linear Regression",
Style: chart.Style{
Show: true,
StrokeColor: chart.ColorAlternateBlue,
StrokeDashArray: []float64{5.0, 5.0},
},
InnerSeries: mainSeries,
}
sma := &chart.SMASeries{
Name: "SMA",
Style: chart.Style{
Show: true,
StrokeColor: chart.ColorRed,
StrokeDashArray: []float64{5.0, 5.0},
},
InnerSeries: mainSeries,
}
graph := chart.Chart{
Width: 1280,
Height: 720,
YAxis: chart.YAxis{
Name: "Elapsed Millis",
NameStyle: chart.StyleShow(),
Style: chart.StyleShow(),
},
XAxis: chart.XAxis{
Style: chart.StyleShow(),
ValueFormatter: chart.TimeHourValueFormatter,
},
Series: []chart.Series{
mainSeries,
minSeries,
maxSeries,
chart.LastValueAnnotation(minSeries),
chart.LastValueAnnotation(maxSeries),
linreg,
chart.LastValueAnnotation(linreg),
sma,
chart.LastValueAnnotation(sma),
},
}
graph.Elements = []chart.Renderable{chart.Legend(&graph)}
res.Header().Set("Content-Type", "image/png")
graph.Render(chart.PNG, res)
}
func main() {
http.HandleFunc("/", drawChart)
http.ListenAndServe(":8080", nil)
}

View file

@ -0,0 +1,170 @@
2016,7,31,16,51.1948264984227130
2016,7,31,17,1.7940833333333333
2016,7,31,18,10.0383889931207000
2016,7,31,19,6.1413707865168539
2016,7,31,20,8.3973734513274336
2016,7,31,21,73.5405406633348480
2016,7,31,22,159.8895444957152270
2016,7,31,23,34.0708326693227090
2016,8,1,0,69.7564325518178730
2016,8,1,1,48.1574708470847080
2016,8,1,2,17.4290324074074070
2016,8,1,3,5.5943366336633663
2016,8,1,4,9.1419949109414758
2016,8,1,5,14.4151891117478510
2016,8,1,6,1.5541666666666667
2016,8,1,7,15.7282261904761900
2016,8,1,8,21.1564157175398630
2016,8,1,9,1.5934583333333333
2016,8,1,10,4.3529166666666667
2016,8,1,11,87.5080657894736840
2016,8,1,12,1.5835000000000000
2016,8,1,13,29.9959344262295080
2016,8,1,14,46.8553964079538170
2016,8,1,15,20.0111057531630460
2016,8,1,16,94.6157284061696660
2016,8,1,17,58.6487434362045140
2016,8,1,18,20.8815984522785900
2016,8,1,19,72.4154909266876360
2016,8,1,20,58.9246686590436590
2016,8,1,21,84.3067604562737640
2016,8,1,22,122.5261538745387450
2016,8,1,23,85.1076058098020120
2016,8,2,0,101.7361568656277570
2016,8,2,1,24.3167470952749810
2016,8,2,2,122.0310546659304250
2016,8,2,3,74.2989314442413160
2016,8,2,4,129.6967691387559810
2016,8,2,5,71.1511239448219070
2016,8,2,6,1.9676388888888889
2016,8,2,7,45.3233373493975900
2016,8,2,8,0.52597727272727272730
2016,8,2,9,0.47493750000000000000
2016,8,2,10,0.36689583333333333330
2016,8,2,11,12.2201858407079650
2016,8,2,12,58.0710813743218810
2016,8,2,13,75.9720821672048800
2016,8,2,14,86.0020336538461540
2016,8,2,15,22.4082420588235290
2016,8,2,16,93.1733733049989880
2016,8,2,17,55.2889921111945910
2016,8,2,18,56.7059533689400160
2016,8,2,19,84.2515716615033430
2016,8,2,20,101.4842500290866780
2016,8,2,21,136.8598881478658540
2016,8,2,22,62.5393413387838530
2016,8,2,23,47.6955947622329430
2016,8,3,0,28.6536128110975110
2016,8,3,1,68.2935053282915090
2016,8,3,2,65.4284130561492130
2016,8,3,3,102.4286141260973660
2016,8,3,4,56.5472182066809920
2016,8,3,5,18.6264831460674160
2016,8,3,6,67.8456661764705880
2016,8,3,7,92.5702828579829460
2016,8,3,8,0.41591666666666666670
2016,8,3,9,0.38620833333333333330
2016,8,3,10,2.4085945945945946
2016,8,3,11,10.7638414634146340
2016,8,3,12,31.4489252873563220
2016,8,3,13,153.4695363601385150
2016,8,3,14,271.2642420287705770
2016,8,3,15,36.5611996434937610
2016,8,3,16,29.2185496806617110
2016,8,3,17,126.9859396924555500
2016,8,3,18,163.7181875191189970
2016,8,3,19,21.4754753134796240
2016,8,3,20,34.1040598911070780
2016,8,3,21,75.1127804170444240
2016,8,3,22,39.4469905441016900
2016,8,3,23,5.1409929328621908
2016,8,4,0,255.8132918813695180
2016,8,4,1,214.4145150846210450
2016,8,4,2,36.1957284522706210
2016,8,4,3,78.4117736768802230
2016,8,4,4,9.9754722222222222
2016,8,4,5,34.1333243123336290
2016,8,4,6,0.39741666666666666670
2016,8,4,7,3.5579206349206349
2016,8,4,8,0.33243750000000000000
2016,8,4,9,0.27264583333333333330
2016,8,4,10,15.6974805194805190
2016,8,4,11,33.3286867469879520
2016,8,4,12,69.0402700057570520
2016,8,4,13,63.8368957232099950
2016,8,4,14,46.5617178867403310
2016,8,4,15,9.4975930656934307
2016,8,4,16,70.3660450209843570
2016,8,4,17,40.3501840688912810
2016,8,4,18,111.0351848094324100
2016,8,4,19,63.0629592505854800
2016,8,4,20,94.2470022670596240
2016,8,4,21,10.0634637203166230
2016,8,4,22,49.0879200762388820
2016,8,4,23,23.7079982971477220
2016,8,5,0,28.9202116946399570
2016,8,5,1,60.5840482187837350
2016,8,5,2,34.2454046076313890
2016,8,5,3,26.3180027100271000
2016,8,5,4,27.4047251497005990
2016,8,5,5,22.3780671462829740
2016,8,5,6,41.4588378921962990
2016,8,5,7,62.6991675955414010
2016,8,5,8,88.7716758230236950
2016,8,5,9,40.4319411764705880
2016,8,5,10,72.9793152507676560
2016,8,5,11,10.6647535971223020
2016,8,5,12,159.3556583236321300
2016,8,5,13,64.6945072587532020
2016,8,5,14,74.9644142216085610
2016,8,5,15,62.0095938270477580
2016,8,5,16,36.5669031007751940
2016,8,5,17,128.6374414414414410
2016,8,5,18,112.1804886168910650
2016,8,5,19,161.8682954545454550
2016,8,5,20,95.8026952301719360
2016,8,5,21,240.8415338457264560
2016,8,5,22,155.3652810287871640
2016,8,5,23,388.9544503679476700
2016,8,6,0,15.9398834146341460
2016,8,6,1,190.7137858942065490
2016,8,6,2,11.4065349143610010
2016,8,6,3,236.7059518272425250
2016,8,6,4,248.0312605042016810
2016,8,6,5,0.24320833333333333330
2016,8,6,6,0.26987500000000000000
2016,8,6,7,0.31525000000000000000
2016,8,6,8,1.2495535714285714
2016,8,6,9,5.4469130434782609
2016,8,6,10,0.33695833333333333330
2016,8,6,11,91.8210377113133940
2016,8,6,12,0.31939583333333333330
2016,8,6,13,7.5832362869198312
2016,8,6,14,7.8081323155216285
2016,8,6,15,54.4206174812030080
2016,8,6,16,1.6644098360655738
2016,8,6,17,120.0108195020746890
2016,8,6,18,128.2539524348810870
2016,8,6,19,93.8680571705426360
2016,8,6,20,1.6764107142857143
2016,8,6,21,24.4085034965034970
2016,8,6,22,96.0146023560209420
2016,8,6,23,7.2911171450737005
2016,8,7,0,22.7146944444444440
2016,8,7,1,0.41214583333333333330
2016,8,7,2,0.30702083333333333330
2016,8,7,3,2.8580312500000000
2016,8,7,4,0.26483333333333333330
2016,8,7,5,0.26022916666666666670
2016,8,7,6,0.27406250000000000000
2016,8,7,7,0.31931250000000000000
2016,8,7,8,0.35614583333333333330
2016,8,7,9,4.6068000000000000
2016,8,7,10,0.36356250000000000000
2016,8,7,11,0.30760416666666666670
2016,8,7,12,23.8985191570881230
2016,8,7,13,4.0653140495867769
2016,8,7,14,61.0720150753768840
2016,8,7,15,14.6478756410256410
2016,8,7,16,53.9795638455827770
2016,8,7,17,97.2232321428571430
1 2016 7 31 16 51.1948264984227130
2 2016 7 31 17 1.7940833333333333
3 2016 7 31 18 10.0383889931207000
4 2016 7 31 19 6.1413707865168539
5 2016 7 31 20 8.3973734513274336
6 2016 7 31 21 73.5405406633348480
7 2016 7 31 22 159.8895444957152270
8 2016 7 31 23 34.0708326693227090
9 2016 8 1 0 69.7564325518178730
10 2016 8 1 1 48.1574708470847080
11 2016 8 1 2 17.4290324074074070
12 2016 8 1 3 5.5943366336633663
13 2016 8 1 4 9.1419949109414758
14 2016 8 1 5 14.4151891117478510
15 2016 8 1 6 1.5541666666666667
16 2016 8 1 7 15.7282261904761900
17 2016 8 1 8 21.1564157175398630
18 2016 8 1 9 1.5934583333333333
19 2016 8 1 10 4.3529166666666667
20 2016 8 1 11 87.5080657894736840
21 2016 8 1 12 1.5835000000000000
22 2016 8 1 13 29.9959344262295080
23 2016 8 1 14 46.8553964079538170
24 2016 8 1 15 20.0111057531630460
25 2016 8 1 16 94.6157284061696660
26 2016 8 1 17 58.6487434362045140
27 2016 8 1 18 20.8815984522785900
28 2016 8 1 19 72.4154909266876360
29 2016 8 1 20 58.9246686590436590
30 2016 8 1 21 84.3067604562737640
31 2016 8 1 22 122.5261538745387450
32 2016 8 1 23 85.1076058098020120
33 2016 8 2 0 101.7361568656277570
34 2016 8 2 1 24.3167470952749810
35 2016 8 2 2 122.0310546659304250
36 2016 8 2 3 74.2989314442413160
37 2016 8 2 4 129.6967691387559810
38 2016 8 2 5 71.1511239448219070
39 2016 8 2 6 1.9676388888888889
40 2016 8 2 7 45.3233373493975900
41 2016 8 2 8 0.52597727272727272730
42 2016 8 2 9 0.47493750000000000000
43 2016 8 2 10 0.36689583333333333330
44 2016 8 2 11 12.2201858407079650
45 2016 8 2 12 58.0710813743218810
46 2016 8 2 13 75.9720821672048800
47 2016 8 2 14 86.0020336538461540
48 2016 8 2 15 22.4082420588235290
49 2016 8 2 16 93.1733733049989880
50 2016 8 2 17 55.2889921111945910
51 2016 8 2 18 56.7059533689400160
52 2016 8 2 19 84.2515716615033430
53 2016 8 2 20 101.4842500290866780
54 2016 8 2 21 136.8598881478658540
55 2016 8 2 22 62.5393413387838530
56 2016 8 2 23 47.6955947622329430
57 2016 8 3 0 28.6536128110975110
58 2016 8 3 1 68.2935053282915090
59 2016 8 3 2 65.4284130561492130
60 2016 8 3 3 102.4286141260973660
61 2016 8 3 4 56.5472182066809920
62 2016 8 3 5 18.6264831460674160
63 2016 8 3 6 67.8456661764705880
64 2016 8 3 7 92.5702828579829460
65 2016 8 3 8 0.41591666666666666670
66 2016 8 3 9 0.38620833333333333330
67 2016 8 3 10 2.4085945945945946
68 2016 8 3 11 10.7638414634146340
69 2016 8 3 12 31.4489252873563220
70 2016 8 3 13 153.4695363601385150
71 2016 8 3 14 271.2642420287705770
72 2016 8 3 15 36.5611996434937610
73 2016 8 3 16 29.2185496806617110
74 2016 8 3 17 126.9859396924555500
75 2016 8 3 18 163.7181875191189970
76 2016 8 3 19 21.4754753134796240
77 2016 8 3 20 34.1040598911070780
78 2016 8 3 21 75.1127804170444240
79 2016 8 3 22 39.4469905441016900
80 2016 8 3 23 5.1409929328621908
81 2016 8 4 0 255.8132918813695180
82 2016 8 4 1 214.4145150846210450
83 2016 8 4 2 36.1957284522706210
84 2016 8 4 3 78.4117736768802230
85 2016 8 4 4 9.9754722222222222
86 2016 8 4 5 34.1333243123336290
87 2016 8 4 6 0.39741666666666666670
88 2016 8 4 7 3.5579206349206349
89 2016 8 4 8 0.33243750000000000000
90 2016 8 4 9 0.27264583333333333330
91 2016 8 4 10 15.6974805194805190
92 2016 8 4 11 33.3286867469879520
93 2016 8 4 12 69.0402700057570520
94 2016 8 4 13 63.8368957232099950
95 2016 8 4 14 46.5617178867403310
96 2016 8 4 15 9.4975930656934307
97 2016 8 4 16 70.3660450209843570
98 2016 8 4 17 40.3501840688912810
99 2016 8 4 18 111.0351848094324100
100 2016 8 4 19 63.0629592505854800
101 2016 8 4 20 94.2470022670596240
102 2016 8 4 21 10.0634637203166230
103 2016 8 4 22 49.0879200762388820
104 2016 8 4 23 23.7079982971477220
105 2016 8 5 0 28.9202116946399570
106 2016 8 5 1 60.5840482187837350
107 2016 8 5 2 34.2454046076313890
108 2016 8 5 3 26.3180027100271000
109 2016 8 5 4 27.4047251497005990
110 2016 8 5 5 22.3780671462829740
111 2016 8 5 6 41.4588378921962990
112 2016 8 5 7 62.6991675955414010
113 2016 8 5 8 88.7716758230236950
114 2016 8 5 9 40.4319411764705880
115 2016 8 5 10 72.9793152507676560
116 2016 8 5 11 10.6647535971223020
117 2016 8 5 12 159.3556583236321300
118 2016 8 5 13 64.6945072587532020
119 2016 8 5 14 74.9644142216085610
120 2016 8 5 15 62.0095938270477580
121 2016 8 5 16 36.5669031007751940
122 2016 8 5 17 128.6374414414414410
123 2016 8 5 18 112.1804886168910650
124 2016 8 5 19 161.8682954545454550
125 2016 8 5 20 95.8026952301719360
126 2016 8 5 21 240.8415338457264560
127 2016 8 5 22 155.3652810287871640
128 2016 8 5 23 388.9544503679476700
129 2016 8 6 0 15.9398834146341460
130 2016 8 6 1 190.7137858942065490
131 2016 8 6 2 11.4065349143610010
132 2016 8 6 3 236.7059518272425250
133 2016 8 6 4 248.0312605042016810
134 2016 8 6 5 0.24320833333333333330
135 2016 8 6 6 0.26987500000000000000
136 2016 8 6 7 0.31525000000000000000
137 2016 8 6 8 1.2495535714285714
138 2016 8 6 9 5.4469130434782609
139 2016 8 6 10 0.33695833333333333330
140 2016 8 6 11 91.8210377113133940
141 2016 8 6 12 0.31939583333333333330
142 2016 8 6 13 7.5832362869198312
143 2016 8 6 14 7.8081323155216285
144 2016 8 6 15 54.4206174812030080
145 2016 8 6 16 1.6644098360655738
146 2016 8 6 17 120.0108195020746890
147 2016 8 6 18 128.2539524348810870
148 2016 8 6 19 93.8680571705426360
149 2016 8 6 20 1.6764107142857143
150 2016 8 6 21 24.4085034965034970
151 2016 8 6 22 96.0146023560209420
152 2016 8 6 23 7.2911171450737005
153 2016 8 7 0 22.7146944444444440
154 2016 8 7 1 0.41214583333333333330
155 2016 8 7 2 0.30702083333333333330
156 2016 8 7 3 2.8580312500000000
157 2016 8 7 4 0.26483333333333333330
158 2016 8 7 5 0.26022916666666666670
159 2016 8 7 6 0.27406250000000000000
160 2016 8 7 7 0.31931250000000000000
161 2016 8 7 8 0.35614583333333333330
162 2016 8 7 9 4.6068000000000000
163 2016 8 7 10 0.36356250000000000000
164 2016 8 7 11 0.30760416666666666670
165 2016 8 7 12 23.8985191570881230
166 2016 8 7 13 4.0653140495867769
167 2016 8 7 14 61.0720150753768840
168 2016 8 7 15 14.6478756410256410
169 2016 8 7 16 53.9795638455827770
170 2016 8 7 17 97.2232321428571430