Debian Codegraph @

examples/stacked_bar/main.go

raw symbols SCIP
1 package main
2
3 import (
4 "os"
5
6 "github.com/wcharczuk/go-chart/v2"
7 )
8
9 func main() {
10 sbc := chart.StackedBarChart{
11 Title: "Test Stacked Bar Chart",
12 Background: chart.Style{
13 Padding: chart.Box{
14 Top: 40,
15 },
16 },
17 Height: 512,
18 Bars: []chart.StackedBar{
19 {
20 Name: "This is a very long string to test word break wrapping.",
21 Values: []chart.Value{
22 {Value: 5, Label: "Blue"},
23 {Value: 5, Label: "Green"},
24 {Value: 4, Label: "Gray"},
25 {Value: 3, Label: "Orange"},
26 {Value: 3, Label: "Test"},
27 {Value: 2, Label: "??"},
28 {Value: 1, Label: "!!"},
29 },
30 },
31 {
32 Name: "Test",
33 Values: []chart.Value{
34 {Value: 10, Label: "Blue"},
35 {Value: 5, Label: "Green"},
36 {Value: 1, Label: "Gray"},
37 },
38 },
39 {
40 Name: "Test 2",
41 Values: []chart.Value{
42 {Value: 10, Label: "Blue"},
43 {Value: 6, Label: "Green"},
44 {Value: 4, Label: "Gray"},
45 },
46 },
47 },
48 }
49
50 f, _ := os.Create("output.png")
51 defer f.Close()
52 sbc.Render(chart.PNG, f)
53 }