Search Apps Documentation Source Content File Folder Download Copy Actions Download

Piechart Documentation

Generate pie charts with label as SVG images.

Basic Usage

 1import "gno.land/p/samcrew/piechart"
 2
 3data := []piechart.PieSlice{
 4    {Value: 35, Color: "#e74c3c", Label: "Category A"},
 5    {Value: 25, Color: "#3498db", Label: "Category B"},
 6    {Value: 20, Color: "#2ecc71", Label: "Category C"},
 7    {Value: 15, Color: "#f39c12", Label: "Category D"},
 8    {Value: 5, Color: "#9b59b6", Label: "Category E"},
 9}
10chart := piechart.Render(data, "Data Distribution Example")

Data Distribution Example

Pie Chart Data Distribution Example


Custom Colors Example

1customData := []piechart.PieSlice{
2    {Value: 40, Color: "#FF6B6B", Label: "Red Section"},
3    {Value: 30, Color: "#4ECDC4", Label: "Teal Section"},
4    {Value: 20, Color: "#45B7D1", Label: "Blue Section"},
5    {Value: 10, Color: "#96CEB4", Label: "Green Section"},
6}
7chart := piechart.Render(customData, "Custom Color Example")

Custom Color Example

Pie Chart Custom Color Example


Simple Split Example

1simpleData := []piechart.PieSlice{
2    {Value: 70, Color: "#FF9F43", Label: "Majority"},
3    {Value: 30, Color: "#686DE0", Label: "Minority"},
4}
5chart := piechart.Render(simpleData, "Simple Split")

Simple Split

Pie Chart Simple Split

API Reference

 1type PieSlice struct {
 2    Value float64 // Numeric value for the slice
 3    Color string  // Hex color code (e.g., "#ff6b6b")
 4    Label string  // Display label for the slice
 5}
 6
 7// slices: Array of PieSlice structs containing the data
 8// title: Chart title (empty string for no title)
 9// Returns: SVG markup as a string
10func Render(slices []PieSlice, title string) string

← Back to Charts | View Package