go-chart/_examples/image_writer/main.go

28 lines
504 B
Go
Raw Normal View History

2016-08-27 23:23:55 +02:00
package main
import (
"fmt"
"log"
2018-12-06 16:46:27 +01:00
"git.gutmet.org/go-chart.git"
2016-08-27 23:23:55 +02:00
)
func main() {
graph := chart.Chart{
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},
},
},
}
collector := &chart.ImageWriter{}
graph.Render(chart.PNG, collector)
image, err := collector.Image()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Final Image: %dx%d\n", image.Bounds().Size().X, image.Bounds().Size().Y)
}