Component Detail

Chart (Pie)

Pie chart for showing part-to-whole proportions.

Example

References

Template
templates/components/chart.html
Golden
N/A

Go (Marionette) Example

This implementation example uses Marionette in Go. Source: docs/site-astro/public/examples/go/chart-pie.go

package goexamples

import (
	mb "github.com/YoshihideShirai/marionette/backend"
	mf "github.com/YoshihideShirai/marionette/frontend"
)

func RegisterChartPieExample(app *mb.App) {
	app.Page("/chart-pie", func(ctx *mb.Context) mf.Node {
		return mf.Chart(mf.ChartProps{
			Type:   mf.ChartTypePie,
			Title:  "Traffic sources",
			Labels: []string{"Search", "Direct", "Referral"},
			Datasets: []mf.ChartDataset{
				{Label: "Sessions", Data: []float64{48, 32, 20}, BackgroundColors: []string{"#2563eb", "#14b8a6", "#f59e0b"}},
			},
		})
	})
}