Search Apps Documentation Source Content File Folder Download Copy Actions Download

Gauge Documentation

Generate progress bars and gauges as SVG images with customizable styling and labels.

Basic Usage

1import "gno.land/p/samcrew/gauge"
2
3// Basic gauge with default config
4gauge := gauge.Render(75, 100, "Progress", "#2ecc71", gauge.DefaultConfig)

Jauge

Custom Configuration Example

1config := gauge.Config{
2    PercentOnly:  true, // Show only percentage
3    Width:        400,  // Custom width in pixels
4    CanvasHeight: 35,   // Custom height in pixels
5    FontSize:     14,   // Font size in pixels
6    PaddingH:     8,    // Horizontal padding in pixels
7}
8gauge := gauge.Render(90, 100, "Loading", "#3498db", config)

Jauge

Different Progress Example

1healthGauge := gauge.Render(33, 50, "Health", "#e74c3c", gauge.DefaultConfig)

Jauge

API Reference

 1type Config struct {
 2    PercentOnly  bool // Only display the percentage on the right side
 3    Width        int  // Width of the gauge in pixels
 4    CanvasHeight int  // Height of the gauge in pixels
 5    FontSize     int  // Font size of the text in pixels
 6    PaddingH     int  // Horizontal padding (for the text) in pixels
 7}
 8
 9var DefaultConfig = Config{
10    PercentOnly:  false,
11    Width:        300,
12    CanvasHeight: 30,
13    FontSize:     16,
14    PaddingH:     6,
15}
16
17// value: Current value (must be ≤ total)
18// total: Maximum value (must be > 0)
19// label: Text label displayed on the left
20// color: Fill color (hex format, e.g., "#4caf50")
21// config: Configuration options
22// Returns: SVG string as markdown image
23func Render(value int, total int, label string, color string, config Config) string

← Back to Charts | View Package