Documentation
¶
Overview ¶
Package chart is a library of Apache ECharts widgets. ECharts is distributed under the Apache License 2.0. See https://echarts.apache.org/ .
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Any = factory.Any
Function aliases
var Bytes = factory.Bytes
var HTML = factory.HTML
var HTMLUnsafe = factory.HTMLUnsafe
var Many = factory.Many
var Tag = factory.Tag
var Text = factory.Text
Functions ¶
This section is empty.
Types ¶
type BytesWidget ¶
type BytesWidget = widget.BytesWidget
type ChartFactory ¶
type ChartFactory struct{}
ChartFactory aggregates the widget constructors of this package.
func (ChartFactory) Chart ¶
func (f ChartFactory) Chart(configTemplate string, data any) *ChartWidget
Chart creates a new ECharts widget.
configTemplate is a Go html/template that, once executed against data, must produce a JavaScript object literal matching the ECharts option spec at https://echarts.apache.org/en/option.html. The template is parsed and executed on every Draw, so keep it small or precompute heavy strings.
Any user-controlled string interpolated into the JS object literal MUST be passed through the `escape` template function, which escapes single and double quotes:
title: {
text: '{{ .Title | escape }}',
}
Note: `escape` only protects against breaking out of a JS string literal — it is not sufficient if you concatenate untrusted text into JS structure or HTML. Prefer numbers and pre-validated values for non-string fields.
Use AsSVG(true) for print-friendly output. To use named maps (e.g. world or US states) blank-import "github.com/microbus-io/bespa/chart/maps".
type ChartWidget ¶
type ChartWidget struct {
*widget.WidgetBase[*ChartWidget]
// contains filtered or unexported fields
}
ChartWidget is a chart from the Apache ECharts library. See https://echarts.apache.org/en/option.html for the configuration reference. ECharts is distributed under the Apache License 2.0.
func (*ChartWidget) AsSVG ¶
func (wgt *ChartWidget) AsSVG(svg bool) *ChartWidget
AsSVG switches the chart to ECharts' SVG renderer instead of the default canvas renderer. SVG output scales cleanly for print and high-DPI displays at some cost in interactive performance for very large datasets.
func (*ChartWidget) WithHeight ¶
func (wgt *ChartWidget) WithHeight(css string) *ChartWidget
WithHeight sets the chart container's height. Pass any CSS length, e.g. "400px", "100%" or "calc(100vh - 50px)". The default (set via CSS) is 400px. Empty falls back to the CSS default.
type InputWidget ¶
type InputWidget = widget.InputWidget