chart

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

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

View Source
var Any = factory.Any

Function aliases

View Source
var Bytes = factory.Bytes
View Source
var HTML = factory.HTML
View Source
var HTMLUnsafe = factory.HTMLUnsafe
View Source
var Many = factory.Many
View Source
var Tag = factory.Tag
View Source
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) Draw

func (wgt *ChartWidget) Draw(w io.Writer, r *http.Request) (err error)

Draw renders the widget's HTML.

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

type Widget

type Widget = widget.Widget

Type aliases

Directories

Path Synopsis
Package maps registers a dynamic GeoJSON server for Apache ECharts maps.
Package maps registers a dynamic GeoJSON server for Apache ECharts maps.

Jump to

Keyboard shortcuts

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