Ship faster with goilerplate templUI Pro

Chart

Beautiful charts. Built using Chart.js.

Source Tailwind CSS JavaScript

Installation

templui add chart

Load the script once in your layout:

<head>
  @chart.Script()
</head>

Examples

Bar Chart - Multiple

Bar Chart - Horizontal

Bar Chart - Negative

Bar Chart - Stacked

Line Chart

Line Chart - Linear

Line Chart - Step

Line Chart - Multiple

RawConfig - Mixed Chart

Area Chart

Area Chart - Linear

Area Chart - Step

Area Chart - Stacked

Pie Chart

Pie Chart - Stacked

Pie Chart - Legend

Doughnut Chart

Doughnut Chart - Stacked

Doughnut Chart - Legend

Radar Chart

Radar Chart - Stacked

API Reference

Required parameter
Hover for description

Chart

Main chart component that renders various chart types.

Name Type Default
ID

Unique identifier for the chart element

string
chart-{randomID}
Variant

Type of chart to render

Variant
-
Data

Chart data configuration including labels and datasets

Data
-
Options

Chart configuration options

Options
{}
RawConfig

Passes a JSON-serializable Chart.js config through directly and bypasses the helper props

map[string]any
nil
ShowLegend

Whether to display the chart legend

bool
false
ShowXAxis

Whether to display the X-axis

bool
false
ShowYAxis

Whether to display the Y-axis

bool
false
ShowXLabels

Whether to display X-axis labels

bool
false
ShowYLabels

Whether to display Y-axis labels

bool
false
ShowXGrid

Whether to display X-axis grid lines

bool
false
ShowYGrid

Whether to display Y-axis grid lines

bool
false
Horizontal

Whether to render the chart horizontally

bool
false
Stacked

Whether to stack chart elements

bool
false
YMin

Minimum value for the Y-axis scale

*float64
nil
YMax

Maximum value for the Y-axis scale

*float64
nil
BeginAtZero

Whether the Y-axis should start at zero. Defaults to true if not specified

*bool
nil (true)
Class

Additional CSS classes to apply to the chart container

string
""
Attributes

Additional HTML attributes to apply to the chart container

templ.Attributes
nil

Use RawConfig as an escape hatch when you need native Chart.js settings that are not covered by the simplified API. When set, templui forwards that config directly to Chart.js and ignores the helper props above.

Axel Adrian