Debian Codegraph @

examples/axes_labels/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 XAxis: chart.XAxis{
20 Name: "The XAxis",
21 },
22 YAxis: chart.YAxis{
23 Name: "The YAxis",
24 },
25 Series: []chart.Series{
26 chart.ContinuousSeries{
27 Style: chart.Style{
28 StrokeColor: chart.GetDefaultColor(0).WithAlpha(64),
29 FillColor: chart.GetDefaultColor(0).WithAlpha(64),
30 },
31 XValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
32 YValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
33 },
34 },
35 }
36
37 f, _ := os.Create("output.png")
38 defer f.Close()
39 graph.Render(chart.PNG, f)
40 }