wchart

package module
v0.0.0-...-d64bbd6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: BSD-2-Clause Imports: 3 Imported by: 0

README

wchart

syscall/js bindings for Chart.js

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Types

type Chart

type Chart struct {
	js.Value
}

func NewChart

func NewChart(ctx js.Value, config *Config) Chart

func (Chart) Decimate

func (c Chart) Decimate(mod int)

Decimate keeps every mod'th point of all datasets. This can be used to improve rendering performance on graphs with many points. Higher mod values yield more aggressive decimation, with mod=2 being the least aggressive possible discarding 1 of every two sample points. mod must be greater than 1. Example: mod=10 discards 9 of every 10 points.

func (Chart) GetConfig

func (c Chart) GetConfig() ConfigHandle

func (Chart) IsHidden

func (c Chart) IsHidden(datasetIdx int) bool

IsHidden returns true if dataset hidden property is set to true.

func (Chart) IsHiddenMeta

func (c Chart) IsHiddenMeta(datasetIdx int) js.Value

IsHiddenMeta is null until user clicks on legend, then it is set to true if user has hidden dataset, or false if dataset is visible.

func (Chart) SetLabels

func (c Chart) SetLabels(newLabels []string)

func (Chart) Update

func (c Chart) Update()

type Clip

type Clip struct {
	Left   float64 `js:"left"`
	Top    float64 `js:"top"`
	Right  float64 `js:"right"`
	Bottom float64 `js:"bottom"`
}

type Config

type Config struct {
	Type    string   `js:"type"`
	Data    Data     `js:"data"`
	Options *Options `js:"options"`
}

type ConfigHandle

type ConfigHandle struct {
	js.Value
}

func (ConfigHandle) AppendFloats

func (ch ConfigHandle) AppendFloats(label string, data []float64)

func (ConfigHandle) ClearChartData

func (ch ConfigHandle) ClearChartData()

ClearChartData destroys dataset `data` fields and config data.labels and sets them to empty array

func (ConfigHandle) Datasets

func (ch ConfigHandle) Datasets() []DatasetHandle

func (ConfigHandle) SetAnimation

func (ch ConfigHandle) SetAnimation(enableAnimation bool)

SetAnimation enables or disables animations for the chart. Usually used for performance reasons or when animations are distracting.

func (ConfigHandle) SetPointRadius

func (ch ConfigHandle) SetPointRadius(pointRadius float64)

SetPointRadius sets the point radius of the chart. Set to zero for performance gains.

func (ConfigHandle) SetShowLine

func (ch ConfigHandle) SetShowLine(enableShowLine bool)

SetShowLine enables/disables line drawing for the chart.

func (ConfigHandle) SetSpanGaps

func (ch ConfigHandle) SetSpanGaps(enableSpanGaps bool)

SetSpanGaps If you have a lot of data points, it can be more performant to enable spanGaps. This disables segmentation of the line, which can be an unneeded step.

type Data

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

type Dataset

type Dataset struct {
	Data            js.Value `js:"data"`
	BackgroundColor js.Value `js:"backgroundColor"`
	BorderColor     js.Value `js:"borderColor"`
	Color           js.Value `js:"color"`
	// The label for the dataset which appears in the legend and tooltips.
	Label string `js:"label"`
	// How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. 0 = clip at chartArea.
	// Clipping can also be configured per side: clip: {left: 5, top: false, right: -2, bottom: 0}
	Clip Clip `js:"clip"`
	// The drawing order of dataset. Also affects order for stacking, tooltip and legend.
	Order int `js:"order"`
	// The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack). Defaults to dataset `type`.
	Stack    string `js:"stack"`
	Parsing  bool   `js:"parsing"`
	Hidden   bool   `js:"hidden"`
	SpanGaps bool   `js:"spanGaps"`
}

type DatasetHandle

type DatasetHandle struct {
	js.Value
}

func (DatasetHandle) AppendFloat

func (dh DatasetHandle) AppendFloat(f float64)

func (DatasetHandle) SetAnimation

func (dh DatasetHandle) SetAnimation(enableAnimation bool)

SetAnimation enables or disables animations for the dataset. Usually used for performance reasons or when animations are distracting.

func (DatasetHandle) SetBackgroundColor

func (dh DatasetHandle) SetBackgroundColor(c color.Color)

func (DatasetHandle) SetBorderColor

func (dh DatasetHandle) SetBorderColor(c color.Color)

SetBorderColor sets outline color of the chart data.

func (DatasetHandle) SetColor

func (dh DatasetHandle) SetColor(c color.Color)

SetColor sets font color

func (DatasetHandle) SetData

func (dh DatasetHandle) SetData(ydata []float64)

func (DatasetHandle) SetHidden

func (dh DatasetHandle) SetHidden(hidden bool)

SetHidden hides/shows dataset data in chart.

func (DatasetHandle) SetPointRadius

func (dh DatasetHandle) SetPointRadius(pointRadius float64)

SetPointRadius sets the point radius of dataset. Set to zero for performance gains.

func (DatasetHandle) SetSpanGaps

func (dh DatasetHandle) SetSpanGaps(enableSpanGaps bool)

SetSpanGaps if the dataset has a lot of data points, it can be more performant to enable spanGaps. This disables segmentation of the line, which can be an unneeded step.

type LabelledXYer

type LabelledXYer interface {
	XYer
	Label() string
}

func LabelXYer

func LabelXYer(label string, xyer XYer) LabelledXYer

type LinePlot

type LinePlot struct {
	Chart
}

func NewLineFromXYers

func NewLineFromXYers(ctx js.Value, xyers ...XYer) LinePlot

NewLineFromXYers plots several XYers on a plot. If an xyer implements the LabelledXYer interface then the dataset is labelled.

type Options

type Options struct {
	Animation bool     `js:"animation"`
	Scales    js.Value `js:"scales"`
	Plugins   js.Value `js:"plugins"`
}

func (*Options) AddPlugins

func (o *Options) AddPlugins(plugins ...Plugin)

type Plugin

type Plugin interface {
	// contains filtered or unexported methods
}

type PluginTitle

type PluginTitle struct {
	Text    string `js:"text"`
	Display bool   `js:"display"`
	Align   string `js:"align"`
}

type RealtimeLinePlot

type RealtimeLinePlot struct {
	Chart
}

func NewRealtimeLinePlot

func NewRealtimeLinePlot(ctx js.Value, xLabels []string, datasets []Dataset) RealtimeLinePlot

func (RealtimeLinePlot) AddData

func (r RealtimeLinePlot) AddData(xLabel string, data []float64)

Call Update after calling AddData to update graph. data must be of length

func (RealtimeLinePlot) ClearChartData

func (r RealtimeLinePlot) ClearChartData()

ClearChartData removes all data from chart.

type XYer

type XYer interface {
	XY(int) (x, y float64)
	Len() int
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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