Debian Codegraph @

examples/logarithmic_axes/main.go

raw symbols SCIP
1 package main
2
3 //go:generate go run main.go
4
5 import (
6 "os"
7
8 "github.com/wcharczuk/go-chart/v2"
9 )
10
11 func main() {
12
13 /*
14 In this example we set the primary YAxis to have logarithmic range.
15 */
16
17 graph := chart.Chart{
18 Background: chart.Style{
19 Padding: chart.Box{
20 Top: 20,
21 Left: 20,
22 },
23 },
24 Series: []chart.Series{
25 chart.ContinuousSeries{
26 Name: "A test series",
27 XValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
28 YValues: []float64{1, 10, 100, 1000, 10000},
29 },
30 },
31 YAxis: chart.YAxis{
32 Style: chart.Shown(),
33 NameStyle: chart.Shown(),
34 Range: &chart.LogarithmicRange{},
35 },
36 }
37
38 f, _ := os.Create("output.png")
39 defer f.Close()
40 graph.Render(chart.PNG, f)
41 }