Type ChartPlot

type ChartPlot struct {
	ChartLayout
	// Plot is the data area inside the axes, where lines and bars are drawn.
	Plot ui.Rect

}

ChartPlot reports where a chart painted, so the caller can turn a pointer position into the hovered data point and place its own annotations.

Constructors

PaintAreaChart#

func PaintAreaChart(canvas *ui.Canvas, theme ui.Theme, bounds ui.Rect, id ui.ID, chart AreaChart, state *ChartState) ChartPlot

PaintAreaChart paints an area or line chart into bounds, with its legend, axes, grid, series, the hover mark and tooltip for state's hovered point, and registers the plot as the hit region id. It returns the geometry for turning pointer positions into points; the caller feeds the result back through ChartState.Hover from its own pointer and key events (ChartStepForKey).

A steady chart allocates nothing per paint once its state has warmed up.

PaintBarChart#

func PaintBarChart(canvas *ui.Canvas, theme ui.Theme, bounds ui.Rect, id ui.ID, chart BarChart, state *ChartState) ChartPlot

PaintBarChart paints a bar chart with the same chrome, state and hover model as PaintAreaChart. Each category owns an equal band; the bars of a group sit side by side, or pile up when Stack is set.

Methods

Count#

func (plot ChartPlot) Count() int

Count is the number of data points.

IndexAt#

func (plot ChartPlot) IndexAt(x float32) int

IndexAt returns the data point nearest to canvas X, or -1 when there is none. Feed it the pointer position to drive ChartState.Hover.

PointX#

func (plot ChartPlot) PointX(index int) float32

PointX is the canvas X of data point index.

ValueY#

func (plot ChartPlot) ValueY(value float32) float32

ValueY is the canvas Y of a Y value.