2016-07-16 23:53:46 -04:00
|
|
|
package main
|
|
|
|
|
2019-09-10 00:02:48 -04:00
|
|
|
//go:generate go run main.go
|
|
|
|
|
2016-07-16 23:53:46 -04:00
|
|
|
import (
|
2019-09-10 00:02:48 -04:00
|
|
|
"os"
|
2016-07-16 23:53:46 -04:00
|
|
|
|
2024-10-27 22:52:38 -04:00
|
|
|
"git.smarteching.com/zeni/go-chart/v2"
|
2016-07-16 23:53:46 -04:00
|
|
|
)
|
|
|
|
|
2019-09-10 00:02:48 -04:00
|
|
|
func main() {
|
2016-07-16 23:53:46 -04:00
|
|
|
/*
|
|
|
|
In this example we set a custom range for the y-axis, overriding the automatic range generation.
|
|
|
|
Note: the chart will still generate the ticks automatically based on the custom range, so the intervals may be a bit weird.
|
|
|
|
*/
|
|
|
|
|
|
|
|
graph := chart.Chart{
|
|
|
|
YAxis: chart.YAxis{
|
2016-07-21 17:14:28 -04:00
|
|
|
Range: &chart.ContinuousRange{
|
2016-07-16 23:53:46 -04:00
|
|
|
Min: 0.0,
|
|
|
|
Max: 10.0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Series: []chart.Series{
|
|
|
|
chart.ContinuousSeries{
|
|
|
|
XValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
|
|
|
|
YValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2019-09-10 00:02:48 -04:00
|
|
|
f, _ := os.Create("output.png")
|
|
|
|
defer f.Close()
|
|
|
|
graph.Render(chart.PNG, f)
|
2016-07-16 23:53:46 -04:00
|
|
|
}
|