Debian Codegraph @

examples/twopoint/main.go

raw symbols SCIP
1 package main
2
3 //go:generate go run main.go
4
5 import (
6 "bytes"
7 "log"
8 "os"
9
10 "github.com/wcharczuk/go-chart/v2"
11 )
12
13 func main() {
14 var b float64
15 b = 1000
16
17 ts1 := chart.ContinuousSeries{ //TimeSeries{
18 Name: "Time Series",
19 XValues: []float64{10 * b, 20 * b, 30 * b, 40 * b, 50 * b, 60 * b, 70 * b, 80 * b},
20 YValues: []float64{1.0, 2.0, 30.0, 4.0, 50.0, 6.0, 7.0, 88.0},
21 }
22
23 ts2 := chart.ContinuousSeries{ //TimeSeries{
24 Style: chart.Style{
25 StrokeColor: chart.GetDefaultColor(1),
26 },
27
28 XValues: []float64{10 * b, 20 * b, 30 * b, 40 * b, 50 * b, 60 * b, 70 * b, 80 * b},
29 YValues: []float64{15.0, 52.0, 30.0, 42.0, 50.0, 26.0, 77.0, 38.0},
30 }
31
32 graph := chart.Chart{
33
34 XAxis: chart.XAxis{
35 Name: "The XAxis",
36 ValueFormatter: chart.TimeMinuteValueFormatter, //TimeHourValueFormatter,
37 },
38
39 YAxis: chart.YAxis{
40 Name: "The YAxis",
41 },
42
43 Series: []chart.Series{
44 ts1,
45 ts2,
46 },
47 }
48
49 buffer := bytes.NewBuffer([]byte{})
50 err := graph.Render(chart.PNG, buffer)
51 if err != nil {
52 log.Fatal(err)
53 }
54
55 fo, err := os.Create("output.png")
56 if err != nil {
57 panic(err)
58 }
59
60 if _, err := fo.Write(buffer.Bytes()); err != nil {
61 panic(err)
62 }
63 }