Debian Codegraph @

examples/axes/main.go

raw symbols SCIP
1 package main
2
3 //go:generate go run main.go
4
5 import (
6 "os"
7
8 chart "github.com/wcharczuk/go-chart/v2"
9 )
10
11 func main() {
12
13 /*
14 The below will draw the same chart as the `basic` example, except with both the x and y axes turned on.
15 In this case, both the x and y axis ticks are generated automatically, the x and y ranges are established automatically, the canvas "box" is adjusted to fit the space the axes occupy so as not to clip.
16 */
17
18 graph := chart.Chart{
19 Series: []chart.Series{
20 chart.ContinuousSeries{
21 Style: chart.Style{
22 StrokeColor: chart.GetDefaultColor(0).WithAlpha(64),
23 FillColor: chart.GetDefaultColor(0).WithAlpha(64),
24 },
25 XValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
26 YValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
27 },
28 },
29 }
30
31 f, _ := os.Create("output.png")
32 defer f.Close()
33 graph.Render(chart.PNG, f)
34 }