Debian Codegraph @

examples/custom_ranges/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 In this example we set a custom range for the y-axis, overriding the automatic range generation.
14 Note: the chart will still generate the ticks automatically based on the custom range, so the intervals may be a bit weird.
15 */
16
17 graph := chart.Chart{
18 YAxis: chart.YAxis{
19 Range: &chart.ContinuousRange{
20 Min: 0.0,
21 Max: 10.0,
22 },
23 },
24 Series: []chart.Series{
25 chart.ContinuousSeries{
26 XValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
27 YValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
28 },
29 },
30 }
31 f, _ := os.Create("output.png")
32 defer f.Close()
33 graph.Render(chart.PNG, f)
34 }