theme/devtools/linechart.go

Functions Structs

Functions

func PaintChart

PaintChart renders a line chart according to DevTools specifications.

func (p LineChartPainter) PaintChart(canvas widget.Canvas, bounds geometry.Rect, state linechart.PaintState) {
	if bounds.IsEmpty() {
		return
	}

	colors := p.resolveColors()

	// Background fill.
	bg := state.Background
	if bg == (widget.Color{}) {
		bg = colors.Background
	}
	canvas.DrawRect(bounds, bg)

	// Compute the plot area (inset for labels if enabled).
	plotArea := dtChartPlotArea(bounds, state.ShowLabels)
	if plotArea.Width() <= 0 || plotArea.Height() <= 0 {
		return
	}

	// Clip to bounds.
	canvas.PushClip(bounds)
	defer canvas.PopClip()

	// Grid lines.
	if state.ShowGrid {
		gridColor := state.GridColor
		if gridColor == (widget.Color{}) {
			gridColor = colors.GridColor
		}
		dtChartDrawGrid(canvas, plotArea, gridColor)
	}

	// Y-axis labels.
	if state.ShowLabels {
		dtChartDrawLabels(canvas, bounds, plotArea, state, colors.LabelColor)
	}

	// Data lines.
	for _, series := range state.Series {
		lineColor := series.Color
		if lineColor == (widget.Color{}) {
			lineColor = colors.LineColor
		}
		dtChartDrawSeries(canvas, plotArea, series, state, lineColor)
	}
}

Structs

type LineChartPainter struct

LineChartPainter renders line charts using DevTools design tokens.

DevTools charts use a dark grid (Gray3 lines on Background), muted axes

(Gray7 text, Gray3 axis lines), and 1.5px line width with Blue6 as the

default series color, matching JetBrains IDE performance monitoring charts.

 

If Theme is nil, LineChartPainter falls back to the default DevTools dark palette.

type LineChartPainter struct {
	Theme *Theme	// nil uses default DevTools dark fallback
}