can rotate text + add y axis names
This commit is contained in:
parent
3607d732d9
commit
718678b421
34 changed files with 102 additions and 20 deletions
62
_examples/stacked_bar/main.go
Normal file
62
_examples/stacked_bar/main.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/wcharczuk/go-chart"
|
||||
)
|
||||
|
||||
func drawChart(res http.ResponseWriter, req *http.Request) {
|
||||
sbc := chart.StackedBarChart{
|
||||
Height: 512,
|
||||
XAxis: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
YAxis: chart.Style{
|
||||
Show: true,
|
||||
},
|
||||
Bars: []chart.StackedBar{
|
||||
{
|
||||
Name: "This is a very long string to test word break wrapping.",
|
||||
Values: []chart.Value{
|
||||
{Value: 5, Label: "Blue"},
|
||||
{Value: 5, Label: "Green"},
|
||||
{Value: 4, Label: "Gray"},
|
||||
{Value: 3, Label: "Orange"},
|
||||
{Value: 3, Label: "Test"},
|
||||
{Value: 2, Label: "??"},
|
||||
{Value: 1, Label: "!!"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "Test",
|
||||
Values: []chart.Value{
|
||||
{Value: 10, Label: "Blue"},
|
||||
{Value: 5, Label: "Green"},
|
||||
{Value: 1, Label: "Gray"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "Test 2",
|
||||
Values: []chart.Value{
|
||||
{Value: 10, Label: "Blue"},
|
||||
{Value: 6, Label: "Green"},
|
||||
{Value: 4, Label: "Gray"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
res.Header().Set("Content-Type", "image/png")
|
||||
err := sbc.Render(chart.PNG, res)
|
||||
if err != nil {
|
||||
fmt.Printf("Error rendering chart: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", drawChart)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue