| 1 |
package main |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import ( |
| 6 |
"os" |
| 7 |
|
| 8 |
"github.com/wcharczuk/go-chart/v2" |
| 9 |
) |
| 10 |
|
| 11 |
func main() { |
| 12 |
graph := chart.BarChart{ |
| 13 |
Title: "Test Bar Chart", |
| 14 |
Background: chart.Style{ |
| 15 |
Padding: chart.Box{ |
| 16 |
Top: 40, |
| 17 |
}, |
| 18 |
}, |
| 19 |
Height: 512, |
| 20 |
BarWidth: 60, |
| 21 |
Bars: []chart.Value{ |
| 22 |
{Value: 5.25, Label: "Blue"}, |
| 23 |
{Value: 4.88, Label: "Green"}, |
| 24 |
{Value: 4.74, Label: "Gray"}, |
| 25 |
{Value: 3.22, Label: "Orange"}, |
| 26 |
{Value: 3, Label: "Test"}, |
| 27 |
{Value: 2.27, Label: "??"}, |
| 28 |
{Value: 1, Label: "!!"}, |
| 29 |
}, |
| 30 |
} |
| 31 |
|
| 32 |
f, _ := os.Create("output.png") |
| 33 |
defer f.Close() |
| 34 |
graph.Render(chart.PNG, f) |
| 35 |
} |