Debian Codegraph @

examples/custom_styles/main.go

raw symbols SCIP
1 package main
2
3 //go:generate go run main.go
4
5 import (
6 "os"
7
8 "github.com/wcharczuk/go-chart/v2"
9 "github.com/wcharczuk/go-chart/v2/drawing"
10 )
11
12 func main() {
13 /*
14 In this example we set some custom colors for the series and the chart background and canvas.
15 */
16 graph := chart.Chart{
17 Background: chart.Style{
18 FillColor: drawing.ColorBlue,
19 },
20 Canvas: chart.Style{
21 FillColor: drawing.ColorFromHex("efefef"),
22 },
23 Series: []chart.Series{
24 chart.ContinuousSeries{
25 Style: chart.Style{
26 StrokeColor: drawing.ColorRed, // will supercede defaults
27 FillColor: drawing.ColorRed.WithAlpha(64), // will supercede defaults
28 },
29 XValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
30 YValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0},
31 },
32 },
33 }
34
35 f, _ := os.Create("output.png")
36 defer f.Close()
37 graph.Render(chart.PNG, f)
38 }