package main import ( "os" "path/filepath" "github.com/vicanso/go-charts/v2" ) func writeFile(buf []byte) error { tmpPath := "./tmp" err := os.MkdirAll(tmpPath, 0700) if err != nil { return err } file := filepath.Join(tmpPath, "funnel-chart.png") err = os.WriteFile(file, buf, 0600) if err != nil { return err } return nil } func main() { values := []float64{ 100, 80, 60, 40, 20, 10, 0, } p, err := charts.FunnelRender( values, charts.TitleTextOptionFunc("Funnel"), charts.LegendLabelsOptionFunc([]string{ "Show", "Click", "Visit", "Inquiry", "Order", "Pay", "Cancel", }), ) if err != nil { panic(err) } buf, err := p.Bytes() if err != nil { panic(err) } err = writeFile(buf) if err != nil { panic(err) } }