forked from wcharczuk/go-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (52 loc) · 1.25 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
//go:generate go run main.go
import (
"os"
"github.com/regorov/go-chart"
)
func main() {
mainSeries := chart.ContinuousSeries{
Name: "A test series",
XValues: chart.Seq{Sequence: chart.NewLinearSequence().WithStart(1.0).WithEnd(100.0)}.Values(),
YValues: chart.Seq{Sequence: chart.NewRandomSequence().WithLen(100).WithMin(50).WithMax(150)}.Values(),
}
minSeries := &chart.MinSeries{
Style: chart.Style{
StrokeColor: chart.ColorAlternateGray,
StrokeDashArray: []float64{5.0, 5.0},
},
InnerSeries: mainSeries,
}
maxSeries := &chart.MaxSeries{
Style: chart.Style{
StrokeColor: chart.ColorAlternateGray,
StrokeDashArray: []float64{5.0, 5.0},
},
InnerSeries: mainSeries,
}
graph := chart.Chart{
Width: 1920,
Height: 1080,
YAxis: chart.YAxis{
Name: "Random Values",
Range: &chart.ContinuousRange{
Min: 25,
Max: 175,
},
},
XAxis: chart.XAxis{
Name: "Random Other Values",
},
Series: []chart.Series{
mainSeries,
minSeries,
maxSeries,
chart.LastValueAnnotationSeries(minSeries),
chart.LastValueAnnotationSeries(maxSeries),
},
}
graph.Elements = []chart.Renderable{chart.Legend(&graph)}
f, _ := os.Create("output.png")
defer f.Close()
graph.Render(chart.PNG, f)
}