Documentation
¶
Overview ¶
Package fyneline provides typed, responsive charts for Fyne applications.
Charts accept application-defined data through accessor functions. This keeps data preparation type-safe while offering the property-oriented, chainable configuration style familiar from LayerChart.
Index ¶
- func Palette(colors ...color.Color) func(index int) color.Color
- func TimeAccessor[T any](accessor func(T) time.Time) func(T) float64
- type ArcChart
- func (c *ArcChart[T]) CreateRenderer() fyne.WidgetRenderer
- func (c *ArcChart[T]) SetCornerRadius(radius float32) *ArcChart[T]
- func (c *ArcChart[T]) SetData(data []T) *ArcChart[T]
- func (c *ArcChart[T]) SetInnerRadius(fraction float32) *ArcChart[T]
- func (c *ArcChart[T]) SetLabels(visible bool) *ArcChart[T]
- func (c *ArcChart[T]) SetMaxValue(value float64) *ArcChart[T]
- func (c *ArcChart[T]) SetOuterRadius(fraction float32) *ArcChart[T]
- func (c *ArcChart[T]) SetPadAngle(degrees float64) *ArcChart[T]
- func (c *ArcChart[T]) SetPadding(padding Insets) *ArcChart[T]
- func (c *ArcChart[T]) SetRange(start, end float64) *ArcChart[T]
- func (c *ArcChart[T]) SetStyle(style func(T, int) ArcStyle) *ArcChart[T]
- type ArcStyle
- type AreaChart
- func (c *AreaChart[T]) CreateRenderer() fyne.WidgetRenderer
- func (c *AreaChart[T]) SetCurve(curve Curve) *AreaChart[T]
- func (c *AreaChart[T]) SetData(data []T) *AreaChart[T]
- func (c *AreaChart[T]) SetGapPolicy(policy GapPolicy) *AreaChart[T]
- func (c *AreaChart[T]) SetPadding(padding Insets) *AreaChart[T]
- func (c *AreaChart[T]) SetSeries(series ...AreaSeries[T]) *AreaChart[T]
- func (c *AreaChart[T]) SetSeriesLayout(layout SeriesLayout) *AreaChart[T]
- func (c *AreaChart[T]) SetXAxis(axis NumericAxis) *AreaChart[T]
- func (c *AreaChart[T]) SetYAxis(axis NumericAxis) *AreaChart[T]
- type AreaSeries
- type AreaStyle
- type AxisStyle
- type BarChart
- func (c *BarChart[T]) CreateRenderer() fyne.WidgetRenderer
- func (c *BarChart[T]) SetBandPadding(padding float32) *BarChart[T]
- func (c *BarChart[T]) SetCategoryAxis(axis CategoryAxis) *BarChart[T]
- func (c *BarChart[T]) SetData(data []T) *BarChart[T]
- func (c *BarChart[T]) SetGroupPadding(padding float32) *BarChart[T]
- func (c *BarChart[T]) SetOrientation(orientation BarOrientation) *BarChart[T]
- func (c *BarChart[T]) SetPadding(padding Insets) *BarChart[T]
- func (c *BarChart[T]) SetSeries(series ...BarSeries[T]) *BarChart[T]
- func (c *BarChart[T]) SetSeriesLayout(layout SeriesLayout) *BarChart[T]
- func (c *BarChart[T]) SetStackPadding(padding float32) *BarChart[T]
- func (c *BarChart[T]) SetValueAxis(axis NumericAxis) *BarChart[T]
- type BarOrientation
- type BarSeries
- type BarStyle
- type CategoryAxis
- func (a CategoryAxis) WithCategories(categories ...string) CategoryAxis
- func (a CategoryAxis) WithFormatter(format func(string) string) CategoryAxis
- func (a CategoryAxis) WithGrid(visible bool) CategoryAxis
- func (a CategoryAxis) WithLabel(label string) CategoryAxis
- func (a CategoryAxis) WithStyle(style AxisStyle) CategoryAxis
- func (a CategoryAxis) WithVisible(visible bool) CategoryAxis
- type Curve
- type Domain
- type FillStyle
- type GapPolicy
- type Insets
- type Number
- type NumericAxis
- func (a NumericAxis) WithAutoDomain() NumericAxis
- func (a NumericAxis) WithDomain(minimum, maximum float64) NumericAxis
- func (a NumericAxis) WithFormatter(format func(float64) string) NumericAxis
- func (a NumericAxis) WithGrid(visible bool) NumericAxis
- func (a NumericAxis) WithLabel(label string) NumericAxis
- func (a NumericAxis) WithStyle(style AxisStyle) NumericAxis
- func (a NumericAxis) WithTickCount(count int) NumericAxis
- func (a NumericAxis) WithVisible(visible bool) NumericAxis
- type SeriesLayout
- type Spline
- func (c *Spline[T]) CreateRenderer() fyne.WidgetRenderer
- func (c *Spline[T]) SetCurve(curve Curve) *Spline[T]
- func (c *Spline[T]) SetData(data []T) *Spline[T]
- func (c *Spline[T]) SetGapPolicy(policy GapPolicy) *Spline[T]
- func (c *Spline[T]) SetPadding(padding Insets) *Spline[T]
- func (c *Spline[T]) SetSeries(series ...SplineSeries[T]) *Spline[T]
- func (c *Spline[T]) SetXAxis(axis NumericAxis) *Spline[T]
- func (c *Spline[T]) SetYAxis(axis NumericAxis) *Spline[T]
- type SplineSeries
- type SplineStyle
- type StrokeStyle
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArcChart ¶
type ArcChart[T any] struct { widget.BaseWidget // contains filtered or unexported fields }
ArcChart displays values as portions of a circle. It supports pie, doughnut, gauge, and partial-circle layouts through its radius and range setters.
func NewArcChart ¶
NewArcChart constructs an arc chart. Angles use degrees, with zero at the top and positive values moving clockwise, matching LayerChart and canvas.Arc.
Example ¶
package main
import (
"image/color"
"github.com/nathabonfim59/fyneline"
)
func main() {
type Segment struct {
Name string
Value float64
}
segments := []Segment{{Name: "Used", Value: 72}, {Name: "Free", Value: 28}}
colors := fyneline.Palette(
color.NRGBA{R: 62, G: 126, B: 247, A: 255},
color.NRGBA{R: 215, G: 220, B: 230, A: 255},
)
chart := fyneline.NewArcChart(segments,
func(s Segment) float64 { return s.Value },
func(s Segment) string { return s.Name },
).
SetInnerRadius(0.58).
SetPadAngle(2).
SetStyle(func(_ Segment, index int) fyneline.ArcStyle {
return fyneline.ArcStyle{Fill: fyneline.FillStyle{Color: colors(index), Opacity: 1}}
})
_ = chart
}
Output:
func (*ArcChart[T]) CreateRenderer ¶
func (c *ArcChart[T]) CreateRenderer() fyne.WidgetRenderer
CreateRenderer implements fyne.Widget.
func (*ArcChart[T]) SetCornerRadius ¶
SetCornerRadius sets arc corner rounding in logical pixels.
func (*ArcChart[T]) SetInnerRadius ¶
SetInnerRadius sets the cutout as a fraction of the outer radius.
func (*ArcChart[T]) SetMaxValue ¶
SetMaxValue fixes the value represented by the complete angular range. It is useful for gauges whose data does not fill the range.
func (*ArcChart[T]) SetOuterRadius ¶
SetOuterRadius sets the outer radius as a fraction of available space.
func (*ArcChart[T]) SetPadAngle ¶
SetPadAngle sets the angular space between adjacent arcs in degrees.
func (*ArcChart[T]) SetPadding ¶
SetPadding sets logical-pixel insets around the chart.
type ArcStyle ¶
type ArcStyle struct {
Fill FillStyle
Stroke StrokeStyle
}
ArcStyle controls an arc's fill and outline.
type AreaChart ¶
type AreaChart[T any] struct { widget.BaseWidget // contains filtered or unexported fields }
AreaChart displays quantitative series as filled areas over a continuous x axis. It defaults to overlapping series with a zero baseline.
func NewAreaChart ¶
func NewAreaChart[T any, X Number](data []T, x func(T) X, series ...AreaSeries[T]) *AreaChart[T]
NewAreaChart constructs an area chart from data, an x accessor, and one or more numerical series.
Example ¶
package main
import (
"time"
"github.com/nathabonfim59/fyneline"
)
func main() {
type Reading struct {
Time time.Time
Value float64
Valid bool
}
readings := []Reading{
{Time: time.Unix(0, 0), Value: 12, Valid: true},
{Time: time.Unix(60, 0), Valid: false},
{Time: time.Unix(120, 0), Value: 15, Valid: true},
}
chart := fyneline.NewAreaChart(readings,
fyneline.TimeAccessor(func(r Reading) time.Time { return r.Time }),
fyneline.NewOptionalAreaSeries("Temperature", func(r Reading) (float64, bool) {
return r.Value, r.Valid
}),
).
SetCurve(fyneline.CurveMonotoneX).
SetXAxis(fyneline.NewTimeAxis("15:04", time.UTC))
_ = chart
}
Output:
func (*AreaChart[T]) CreateRenderer ¶
func (c *AreaChart[T]) CreateRenderer() fyne.WidgetRenderer
CreateRenderer implements fyne.Widget.
func (*AreaChart[T]) SetGapPolicy ¶
SetGapPolicy controls how optional series values are connected.
func (*AreaChart[T]) SetPadding ¶
SetPadding sets logical-pixel insets around the chart.
func (*AreaChart[T]) SetSeries ¶
func (c *AreaChart[T]) SetSeries(series ...AreaSeries[T]) *AreaChart[T]
SetSeries replaces the displayed series and refreshes the widget.
func (*AreaChart[T]) SetSeriesLayout ¶
func (c *AreaChart[T]) SetSeriesLayout(layout SeriesLayout) *AreaChart[T]
SetSeriesLayout selects overlap, stack, normalized stack, or diverging stack. SeriesGroup is treated as SeriesOverlap for area charts.
func (*AreaChart[T]) SetXAxis ¶
func (c *AreaChart[T]) SetXAxis(axis NumericAxis) *AreaChart[T]
SetXAxis replaces the x-axis configuration.
func (*AreaChart[T]) SetYAxis ¶
func (c *AreaChart[T]) SetYAxis(axis NumericAxis) *AreaChart[T]
SetYAxis replaces the y-axis configuration.
type AreaSeries ¶
type AreaSeries[T any] struct { // contains filtered or unexported fields }
AreaSeries describes one named set of values in an AreaChart.
func NewAreaSeries ¶
func NewAreaSeries[T any, N Number](name string, value func(T) N) AreaSeries[T]
NewAreaSeries creates an area series from a required numeric accessor.
func NewOptionalAreaSeries ¶
func NewOptionalAreaSeries[T any, N Number](name string, value func(T) (N, bool)) AreaSeries[T]
NewOptionalAreaSeries creates an area series whose accessor can report gaps.
func (AreaSeries[T]) WithFill ¶
func (s AreaSeries[T]) WithFill(c color.Color) AreaSeries[T]
WithFill returns a copy of the series filled with c.
func (AreaSeries[T]) WithStroke ¶
func (s AreaSeries[T]) WithStroke(stroke StrokeStyle) AreaSeries[T]
WithStroke returns a copy of the series using stroke.
func (AreaSeries[T]) WithStyle ¶
func (s AreaSeries[T]) WithStyle(style AreaStyle) AreaSeries[T]
WithStyle returns a copy of the series using style.
type AreaStyle ¶
type AreaStyle struct {
Fill FillStyle
Stroke StrokeStyle
}
AreaStyle controls an area's fill and boundary line.
type AxisStyle ¶
type AxisStyle struct {
LineColor color.Color
LabelColor color.Color
GridColor color.Color
LineWidth float32
TextSize float32
}
AxisStyle controls axis, grid, and label appearance. Nil colors use the active Fyne theme.
type BarChart ¶
type BarChart[T any] struct { widget.BaseWidget // contains filtered or unexported fields }
BarChart displays categorical data using rectangular bars. It defaults to vertical, overlapping series with LayerChart-compatible band padding.
func NewBarChart ¶
NewBarChart constructs a category-based bar chart. Categories appear in first-seen order unless CategoryAxis.WithCategories supplies an order.
Example ¶
package main
import (
"github.com/nathabonfim59/fyneline"
)
func main() {
type Sale struct {
Month string
Online float64
InStore float64
}
sales := []Sale{
{Month: "Jan", Online: 42, InStore: 31},
{Month: "Feb", Online: 55, InStore: 38},
{Month: "Mar", Online: 49, InStore: 44},
}
chart := fyneline.NewBarChart(sales,
func(s Sale) string { return s.Month },
fyneline.NewBarSeries("Online", func(s Sale) float64 { return s.Online }),
fyneline.NewBarSeries("In store", func(s Sale) float64 { return s.InStore }),
).
SetSeriesLayout(fyneline.SeriesGroup).
SetValueAxis(fyneline.NewNumericAxis().WithDomain(0, 60))
_ = chart // Pass chart directly to Window.SetContent.
}
Output:
func (*BarChart[T]) CreateRenderer ¶
func (c *BarChart[T]) CreateRenderer() fyne.WidgetRenderer
CreateRenderer implements fyne.Widget.
func (*BarChart[T]) SetBandPadding ¶
SetBandPadding sets the empty fraction of each category band. Values outside [0, 1) are replaced by the default 0.4.
func (*BarChart[T]) SetCategoryAxis ¶
func (c *BarChart[T]) SetCategoryAxis(axis CategoryAxis) *BarChart[T]
SetCategoryAxis replaces the category-axis configuration.
func (*BarChart[T]) SetGroupPadding ¶
SetGroupPadding sets the empty fraction between bars in a grouped band.
func (*BarChart[T]) SetOrientation ¶
func (c *BarChart[T]) SetOrientation(orientation BarOrientation) *BarChart[T]
SetOrientation selects vertical or horizontal bars.
func (*BarChart[T]) SetPadding ¶
SetPadding sets logical-pixel insets around the chart.
func (*BarChart[T]) SetSeriesLayout ¶
func (c *BarChart[T]) SetSeriesLayout(layout SeriesLayout) *BarChart[T]
SetSeriesLayout selects overlap, stack, normalized stack, diverging stack, or grouped rendering.
func (*BarChart[T]) SetStackPadding ¶
SetStackPadding sets the empty fraction removed from stacked bar edges.
func (*BarChart[T]) SetValueAxis ¶
func (c *BarChart[T]) SetValueAxis(axis NumericAxis) *BarChart[T]
SetValueAxis replaces the value-axis configuration.
type BarOrientation ¶
type BarOrientation uint8
BarOrientation controls the direction in which bars grow.
const ( // BarVertical displays categories horizontally and values vertically. BarVertical BarOrientation = iota // BarHorizontal displays categories vertically and values horizontally. BarHorizontal )
type BarSeries ¶
type BarSeries[T any] struct { // contains filtered or unexported fields }
BarSeries describes one named set of values in a BarChart.
func NewBarSeries ¶
NewBarSeries creates a bar series from a required numeric accessor.
func NewOptionalBarSeries ¶
NewOptionalBarSeries creates a bar series whose accessor can report gaps.
func (BarSeries[T]) WithStroke ¶
func (s BarSeries[T]) WithStroke(stroke StrokeStyle) BarSeries[T]
WithStroke returns a copy of the series using stroke.
type BarStyle ¶
type BarStyle struct {
Fill FillStyle
Stroke StrokeStyle
CornerRadius float32
}
BarStyle controls a bar's fill, outline, and corner radius.
type CategoryAxis ¶
type CategoryAxis struct {
// contains filtered or unexported fields
}
CategoryAxis configures a discrete category axis. Build one with NewCategoryAxis and customize it using its With methods.
func NewCategoryAxis ¶
func NewCategoryAxis() CategoryAxis
NewCategoryAxis returns a visible category axis using data order.
func (CategoryAxis) WithCategories ¶
func (a CategoryAxis) WithCategories(categories ...string) CategoryAxis
WithCategories returns an axis with an explicit category order.
func (CategoryAxis) WithFormatter ¶
func (a CategoryAxis) WithFormatter(format func(string) string) CategoryAxis
WithFormatter returns an axis that formats category labels with format.
func (CategoryAxis) WithGrid ¶
func (a CategoryAxis) WithGrid(visible bool) CategoryAxis
WithGrid returns an axis with grid lines enabled or disabled.
func (CategoryAxis) WithLabel ¶
func (a CategoryAxis) WithLabel(label string) CategoryAxis
WithLabel returns an axis with the supplied title.
func (CategoryAxis) WithStyle ¶
func (a CategoryAxis) WithStyle(style AxisStyle) CategoryAxis
WithStyle returns an axis using style.
func (CategoryAxis) WithVisible ¶
func (a CategoryAxis) WithVisible(visible bool) CategoryAxis
WithVisible returns an axis with its line, ticks, and labels shown or hidden.
type Curve ¶
type Curve uint8
Curve controls how points are connected.
const ( // CurveLinear connects points with straight lines. CurveLinear Curve = iota // CurveMonotoneX connects points smoothly without introducing local extrema. CurveMonotoneX // CurveStep changes value halfway between adjacent points. CurveStep // CurveStepBefore changes value before moving to the next x position. CurveStepBefore // CurveStepAfter changes value after moving from the current x position. CurveStepAfter )
type Domain ¶
type Domain struct {
Min, Max float64
}
Domain specifies the inclusive minimum and maximum values of an axis.
type FillStyle ¶
FillStyle describes the interior of a rendered mark. An opacity greater than zero is clamped to one; zero uses the mark's default opacity.
type GapPolicy ¶
type GapPolicy uint8
GapPolicy controls how a series handles values reported as missing.
type Insets ¶
type Insets struct {
Top, Right, Bottom, Left float32
}
Insets specifies logical-pixel padding around a chart's plot area.
type Number ¶
type Number interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
~float32 | ~float64
}
Number is a numeric value accepted by chart accessors.
type NumericAxis ¶
type NumericAxis struct {
// contains filtered or unexported fields
}
NumericAxis configures a continuous numeric axis. Build one with NewNumericAxis and customize it using its With methods.
func NewNumericAxis ¶
func NewNumericAxis() NumericAxis
NewNumericAxis returns a visible, automatically ranged numeric axis.
func NewTimeAxis ¶
func NewTimeAxis(layout string, location *time.Location) NumericAxis
NewTimeAxis returns a numeric axis formatted using layout and location. A nil location formats values in time.Local.
func (NumericAxis) WithAutoDomain ¶
func (a NumericAxis) WithAutoDomain() NumericAxis
WithAutoDomain returns an axis whose domain is inferred from its data.
func (NumericAxis) WithDomain ¶
func (a NumericAxis) WithDomain(minimum, maximum float64) NumericAxis
WithDomain returns an axis fixed to the supplied domain.
func (NumericAxis) WithFormatter ¶
func (a NumericAxis) WithFormatter(format func(float64) string) NumericAxis
WithFormatter returns an axis that formats tick values with format.
func (NumericAxis) WithGrid ¶
func (a NumericAxis) WithGrid(visible bool) NumericAxis
WithGrid returns an axis with grid lines enabled or disabled.
func (NumericAxis) WithLabel ¶
func (a NumericAxis) WithLabel(label string) NumericAxis
WithLabel returns an axis with the supplied title.
func (NumericAxis) WithStyle ¶
func (a NumericAxis) WithStyle(style AxisStyle) NumericAxis
WithStyle returns an axis using style.
func (NumericAxis) WithTickCount ¶
func (a NumericAxis) WithTickCount(count int) NumericAxis
WithTickCount returns an axis targeting count labeled ticks.
func (NumericAxis) WithVisible ¶
func (a NumericAxis) WithVisible(visible bool) NumericAxis
WithVisible returns an axis with its line, ticks, and labels shown or hidden.
type SeriesLayout ¶
type SeriesLayout uint8
SeriesLayout controls how multiple series share the same chart space.
const ( // SeriesOverlap draws each series independently in the same plot area. SeriesOverlap SeriesLayout = iota // SeriesStack places each series on top of the preceding series. SeriesStack // SeriesStackExpand normalizes each stack to a total of one. SeriesStackExpand // SeriesStackDiverging stacks positive and negative values away from zero. SeriesStackDiverging // SeriesGroup places series beside each other. It is supported by BarChart. SeriesGroup )
type Spline ¶
type Spline[T any] struct { widget.BaseWidget // contains filtered or unexported fields }
Spline displays one or more numerical series as connected lines. Although LayerChart exposes Spline as a composable mark, Fyneline makes it a complete, responsive Fyne widget with axes and grid configuration.
func NewSpline ¶
func NewSpline[T any, X Number](data []T, x func(T) X, series ...SplineSeries[T]) *Spline[T]
NewSpline constructs a spline from data, an x accessor, and one or more numerical series. The default curve is CurveLinear, matching LayerChart.
Example ¶
package main
import (
"github.com/nathabonfim59/fyneline"
)
func main() {
type Point struct{ X, Y float64 }
points := []Point{{X: 0, Y: 2}, {X: 1, Y: 5}, {X: 2, Y: 3}}
chart := fyneline.NewSpline(points,
func(p Point) float64 { return p.X },
fyneline.NewSplineSeries("Value", func(p Point) float64 { return p.Y }),
).SetCurve(fyneline.CurveMonotoneX)
_ = chart
}
Output:
func (*Spline[T]) CreateRenderer ¶
func (c *Spline[T]) CreateRenderer() fyne.WidgetRenderer
CreateRenderer implements fyne.Widget.
func (*Spline[T]) SetGapPolicy ¶
SetGapPolicy controls how optional series values are connected.
func (*Spline[T]) SetPadding ¶
SetPadding sets logical-pixel insets around the chart.
func (*Spline[T]) SetSeries ¶
func (c *Spline[T]) SetSeries(series ...SplineSeries[T]) *Spline[T]
SetSeries replaces the displayed series and refreshes the widget.
func (*Spline[T]) SetXAxis ¶
func (c *Spline[T]) SetXAxis(axis NumericAxis) *Spline[T]
SetXAxis replaces the x-axis configuration.
func (*Spline[T]) SetYAxis ¶
func (c *Spline[T]) SetYAxis(axis NumericAxis) *Spline[T]
SetYAxis replaces the y-axis configuration.
type SplineSeries ¶
type SplineSeries[T any] struct { // contains filtered or unexported fields }
SplineSeries describes one named set of values in a Spline.
func NewOptionalSplineSeries ¶
func NewOptionalSplineSeries[T any, N Number](name string, value func(T) (N, bool)) SplineSeries[T]
NewOptionalSplineSeries creates a spline series whose accessor can report gaps.
func NewSplineSeries ¶
func NewSplineSeries[T any, N Number](name string, value func(T) N) SplineSeries[T]
NewSplineSeries creates a spline series from a required numeric accessor.
func (SplineSeries[T]) WithColor ¶
func (s SplineSeries[T]) WithColor(c color.Color) SplineSeries[T]
WithColor returns a copy of the series using c.
func (SplineSeries[T]) WithStyle ¶
func (s SplineSeries[T]) WithStyle(style SplineStyle) SplineSeries[T]
WithStyle returns a copy of the series using style.
func (SplineSeries[T]) WithWidth ¶
func (s SplineSeries[T]) WithWidth(width float32) SplineSeries[T]
WithWidth returns a copy of the series using width.
type SplineStyle ¶
type SplineStyle struct {
Stroke StrokeStyle
}
SplineStyle controls a spline's line.
type StrokeStyle ¶
StrokeStyle describes the outline of a rendered mark.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
arc-chart
Package arcchart contains the ArcChart example gallery.
|
Package arcchart contains the ArcChart example gallery. |
|
arc-chart/cmd
command
|
|
|
area-chart
Package areachart contains the AreaChart example gallery.
|
Package areachart contains the AreaChart example gallery. |
|
area-chart/cmd
command
|
|
|
bar-chart
Package barchart contains the BarChart example gallery.
|
Package barchart contains the BarChart example gallery. |
|
bar-chart/cmd
command
|
|
|
internal/gallery
Package gallery contains presentation helpers shared by the example apps.
|
Package gallery contains presentation helpers shared by the example apps. |
|
render
command
Command render regenerates the screenshots used by the example READMEs.
|
Command render regenerates the screenshots used by the example READMEs. |
|
spline
Package spline contains the Spline example gallery.
|
Package spline contains the Spline example gallery. |
|
spline/cmd
command
|



