chart

package
v1.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

templ: version: v0.3.1001

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool added in v1.13.0

func Bool(v bool) *bool

Bool returns a pointer for tri-state option fields.

func Chart

func Chart(props ...Props) templ.Component

func Script

func Script() templ.Component

Types

type Config

type Config struct {
	Type        Variant  `json:"type"`
	Data        Data     `json:"data"`
	Options     Options  `json:"options,omitempty"`
	ShowLegend  bool     `json:"showLegend,omitempty"`
	ShowXAxis   bool     `json:"showXAxis"`
	ShowYAxis   bool     `json:"showYAxis"`
	ShowXLabels bool     `json:"showXLabels"`
	ShowYLabels bool     `json:"showYLabels"`
	ShowXGrid   bool     `json:"showXGrid"`
	ShowYGrid   bool     `json:"showYGrid"`
	Horizontal  bool     `json:"horizontal"`
	Stacked     bool     `json:"stacked"`
	YMin        *float64 `json:"yMin,omitempty"`
	YMax        *float64 `json:"yMax,omitempty"`
	BeginAtZero *bool    `json:"beginAtZero,omitempty"`
}

type Data

type Data struct {
	Labels   []string  `json:"labels"`
	Datasets []Dataset `json:"datasets"`
}

type Dataset

type Dataset struct {
	Label           string      `json:"label"`
	Data            []float64   `json:"data"`
	BorderWidth     int         `json:"borderWidth,omitempty"`
	BorderColor     interface{} `json:"borderColor,omitempty"`
	BackgroundColor interface{} `json:"backgroundColor,omitempty"`
	Tension         float64     `json:"tension,omitempty"`
	Fill            bool        `json:"fill,omitempty"`
	Stepped         bool        `json:"stepped,omitempty"`
}

type Options

type Options struct {
	// Responsive is tri-state: nil keeps Chart.js' default (true), an
	// explicit false via chart.Bool(false) turns it off (#592).
	Responsive *bool `json:"responsive,omitempty"`
	Legend     bool  `json:"legend,omitempty"`
}

type Props

type Props struct {
	ID          string
	Variant     Variant
	Data        Data
	Options     Options
	RawConfig   map[string]any
	ShowLegend  bool
	ShowXAxis   bool
	ShowYAxis   bool
	ShowXLabels bool
	ShowYLabels bool
	ShowXGrid   bool
	ShowYGrid   bool
	Horizontal  bool
	Stacked     bool
	YMin        *float64
	YMax        *float64
	BeginAtZero *bool
	Class       string
	Attributes  templ.Attributes
}

type ScriptConfig added in v1.8.0

type ScriptConfig struct {
	RawConfig       map[string]any `json:"rawConfig,omitempty"`
	GeneratedConfig *Config        `json:"generatedConfig,omitempty"`
}

type Variant

type Variant string
const (
	VariantBar      Variant = "bar"
	VariantLine     Variant = "line"
	VariantPie      Variant = "pie"
	VariantDoughnut Variant = "doughnut"
	VariantRadar    Variant = "radar"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL