charts

package
v0.0.0-...-ebd8699 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package charts provides Go bindings for Apple's Charts framework.

The package integrates with swiftui.View and focuses on the practical Swift Charts surface needed for real dashboards, SRE charts, and ML plots: line, area, bar, point, rule, rectangle, and sector marks; domains and scale types; axes and legends; foreground style scales; annotations; and scrollable time-series presentation.

Bridge sources under internal/swift/ are generated by go generate.

Quick start

import (
	"time"

	"github.com/tmc/swiftui"
	"github.com/tmc/swiftui/charts"
)

view := charts.Chart(
	charts.LineMark(
		charts.X(charts.TimeValue("Time", time.Now(), charts.TimeUnitMinute)),
		charts.Y(charts.NumberValue("Latency", 182.4)),
	).ForegroundStyle(swiftui.RGB(0.18, 0.36, 0.79)),
).ChartYScaleType(charts.ScaleTypeLog).View()

_ = view
Example (BarChart)
package main

import (
	"github.com/tmc/swiftui"
	"github.com/tmc/swiftui/charts"
)

func main() {
	view := charts.Chart(
		charts.BarMark(
			charts.X(charts.CategoryValue("Service", "api")),
			charts.Y(charts.NumberValue("Errors", 12)),
		).ForegroundStyle(swiftui.RGB(0.78, 0.22, 0.22)),
		charts.BarMark(
			charts.X(charts.CategoryValue("Service", "worker")),
			charts.Y(charts.NumberValue("Errors", 4)),
		).ForegroundStyle(swiftui.RGB(0.28, 0.48, 0.84)),
	).ChartLegend(charts.LegendHidden)

	_ = view.View()
}
Example (ConfidenceIntervalChart)
package main

import (
	"github.com/tmc/swiftui"
	"github.com/tmc/swiftui/charts"
)

func main() {
	view := charts.Chart(
		charts.ErrorBarMark(
			charts.XFloatRange("95% CI", 71, 86),
			charts.YString("Experiment", "baseline"),
			charts.HeightFixed(10),
		).ForegroundStyle(swiftui.RGB(0.57, 0.59, 0.63)),
		charts.PointMark(
			charts.XFloat("Mean", 78),
			charts.YString("Experiment", "baseline"),
		).ForegroundStyle(swiftui.RGB(0.15, 0.45, 0.27)).Symbol(charts.SymbolCircle).SymbolSize(40),
		charts.ErrorBarMark(
			charts.XFloatRange("95% CI", 83, 97),
			charts.YString("Experiment", "candidate"),
			charts.HeightFixed(10),
		).ForegroundStyle(swiftui.RGB(0.57, 0.59, 0.63)),
		charts.PointMark(
			charts.XFloat("Mean", 90),
			charts.YString("Experiment", "candidate"),
		).ForegroundStyle(swiftui.RGB(0.15, 0.45, 0.27)).Symbol(charts.SymbolDiamond).SymbolSize(40),
	).ChartXAxis(charts.AxisMarks(
		charts.AxisGridLines(),
		charts.AxisValueLabels(charts.FixedFormat(0)),
	))

	_ = view.View()
}
Example (DeltaChart)
package main

import (
	"github.com/tmc/swiftui"
	"github.com/tmc/swiftui/charts"
)

func main() {
	view := charts.Chart(
		charts.RangeBarMark(
			charts.XFloatRange("Delta", -0.12, 0.08),
			charts.YString("Benchmark", "Decode/large"),
		).ForegroundStyle(swiftui.RGBA(0.86, 0.38, 0.26, 0.8)).TextAnnotation("-12%", charts.AnnotationLeading),
		charts.RangeBarMark(
			charts.XFloatRange("Delta", 0.0, 0.17),
			charts.YString("Benchmark", "Encode/small"),
		).ForegroundStyle(swiftui.RGBA(0.21, 0.58, 0.28, 0.82)).TextAnnotation("+17%", charts.AnnotationTrailing),
		charts.ReferenceLineX(charts.NumberValue("Baseline", 0), "baseline").
			LineStyle(charts.Stroke(1, 3, 2)),
	).ChartXScaleDomain(charts.NumberDomain(-0.2, 0.2)).
		ChartXAxis(charts.AxisMarks(
			charts.AxisGridLinesStyled(charts.Stroke(0.75, 2, 2), false),
			charts.AxisValueLabels(charts.PercentFormat(0)),
		)).
		ChartLegend(charts.LegendHidden)

	_ = view.View()
}
Example (GroupedBenchmarkBars)
package main

import (
	"github.com/tmc/swiftui/charts"
)

func main() {
	view := charts.Chart(
		charts.BarMark(
			charts.XFloat("ns/op", 1823),
			charts.YString("Benchmark", "Encode/small"),
			charts.HeightFixed(14),
		).PositionBy("Run", "old").ForegroundStyleBy("Run", "old").TextAnnotation("1823", charts.AnnotationTrailing),
		charts.BarMark(
			charts.XFloat("ns/op", 1312),
			charts.YString("Benchmark", "Encode/small"),
			charts.HeightFixed(14),
		).PositionBy("Run", "new").ForegroundStyleBy("Run", "new").TextAnnotation("1312", charts.AnnotationTrailing),
		charts.BarMark(
			charts.XFloat("ns/op", 4180),
			charts.YString("Benchmark", "Decode/large"),
			charts.HeightFixed(14),
		).PositionBy("Run", "old").ForegroundStyleBy("Run", "old"),
		charts.BarMark(
			charts.XFloat("ns/op", 3540),
			charts.YString("Benchmark", "Decode/large"),
			charts.HeightFixed(14),
		).PositionBy("Run", "new").ForegroundStyleBy("Run", "new"),
	).ChartLegend(charts.LegendCompact(charts.LegendPositionTop, charts.LegendAlignmentLeading)).
		ChartXAxis(charts.AxisMarks(
			charts.AxisGridLines(),
			charts.AxisValueLabels(charts.CompactFormat(1)),
		))

	_ = view.View()
}
Example (LineChart)
package main

import (
	"time"

	"github.com/tmc/swiftui/charts"
)

func main() {
	now := time.Now()
	view := charts.Chart(
		charts.LineMark(
			charts.X(charts.TimeValue("Time", now.Add(-2*time.Minute), charts.TimeUnitMinute)),
			charts.Y(charts.NumberValue("Latency", 145)),
		).ForegroundStyleBy("Series", "p95").Symbol(charts.SymbolCircle),
		charts.LineMark(
			charts.X(charts.TimeValue("Time", now.Add(-1*time.Minute), charts.TimeUnitMinute)),
			charts.Y(charts.NumberValue("Latency", 162)),
		).ForegroundStyleBy("Series", "p95").Symbol(charts.SymbolCircle),
		charts.LineMark(
			charts.X(charts.TimeValue("Time", now, charts.TimeUnitMinute)),
			charts.Y(charts.NumberValue("Latency", 180)),
		).ForegroundStyleBy("Series", "p95").Symbol(charts.SymbolCircle),
	).ChartXVisibleDomainLength(180).ChartScrollableAxes(charts.ScrollAxisHorizontal)

	_ = view.View()
}
Example (MixedChart)
package main

import (
	"time"

	"github.com/tmc/swiftui"
	"github.com/tmc/swiftui/charts"
)

func main() {
	now := time.Now()
	view := charts.Chart(
		charts.RectangleMark(
			charts.XDateRange("Window", now.Add(-time.Minute), now, charts.TimeUnitMinute),
			charts.YFloatRange("Band", 110, 190),
		).ForegroundStyle(swiftui.RGBA(0.18, 0.36, 0.79, 0.16)),
		charts.LineMark(
			charts.X(charts.TimeValue("Time", now, charts.TimeUnitMinute)),
			charts.Y(charts.NumberValue("Mean", 150)),
		).ForegroundStyle(swiftui.RGB(0.18, 0.36, 0.79)),
		charts.RuleMark(
			charts.Y(charts.NumberValue("SLO", 175)),
		).LineStyle(charts.Stroke(1.5, 4, 2)),
	).ChartYScaleDomain(charts.NumberDomain(100, 220))

	_ = view.View()
}

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	InterpolationLinear     = InterpolationMethod{/* contains filtered or unexported fields */}
	InterpolationCatmullRom = InterpolationMethod{/* contains filtered or unexported fields */}
	InterpolationCardinal   = InterpolationMethod{/* contains filtered or unexported fields */}
	InterpolationMonotone   = InterpolationMethod{/* contains filtered or unexported fields */}
	InterpolationStepStart  = InterpolationMethod{/* contains filtered or unexported fields */}
	InterpolationStepCenter = InterpolationMethod{/* contains filtered or unexported fields */}
	InterpolationStepEnd    = InterpolationMethod{/* contains filtered or unexported fields */}
)
View Source
var (
	ScaleTypeAutomatic  = ScaleType{/* contains filtered or unexported fields */}
	ScaleTypeLinear     = ScaleType{/* contains filtered or unexported fields */}
	ScaleTypeLog        = ScaleType{/* contains filtered or unexported fields */}
	ScaleTypeDate       = ScaleType{/* contains filtered or unexported fields */}
	ScaleTypeCategory   = ScaleType{/* contains filtered or unexported fields */}
	ScaleTypeSquareRoot = ScaleType{/* contains filtered or unexported fields */}
)
View Source
var AxisHidden = AxisConfig{/* contains filtered or unexported fields */}

AxisHidden hides an axis.

View Source
var AxisTickLengthAutomatic = AxisTickLength{/* contains filtered or unexported fields */}
View Source
var LegendHidden = LegendConfig{Visibility: LegendVisibilityHidden}

LegendHidden hides the legend.

View Source
var MajorValueAlignmentPage = MajorValueAlignment{/* contains filtered or unexported fields */}
View Source
var MarkDimensionAutomatic = MarkDimension{/* contains filtered or unexported fields */}

MarkDimensionAutomatic uses the framework default sizing.

View Source
var PagingScrollTarget = ScrollTargetBehavior{/* contains filtered or unexported fields */}

PagingScrollTarget snaps by pages.

View Source
var ValueFormatAutomatic = ValueFormat{/* contains filtered or unexported fields */}

ValueFormatAutomatic uses the framework default label formatting.

Functions

func VisibleDomainNumeric

func VisibleDomainNumeric(length float64) visibleDomainLength

VisibleDomainNumeric uses a numeric visible-domain length.

func VisibleDomainTime

func VisibleDomainTime(length time.Duration) visibleDomainLength

VisibleDomainTime uses a time-domain visible length.

Types

type AnnotationAlignment

type AnnotationAlignment int32

AnnotationAlignment controls annotation alignment.

const (
	AnnotationAlignmentCenter AnnotationAlignment = iota
	AnnotationAlignmentLeading
	AnnotationAlignmentTrailing
	AnnotationAlignmentTop
	AnnotationAlignmentBottom
)

type AnnotationCollisionMode

type AnnotationCollisionMode int32

AnnotationCollisionMode controls built-in annotation collision resolution.

const (
	AnnotationCollisionAutomatic AnnotationCollisionMode = iota
	AnnotationCollisionHideOverlapping
	AnnotationCollisionKeepLatest
	AnnotationCollisionKeepPriority
)

type AnnotationOverflowStrategy

type AnnotationOverflowStrategy int32

AnnotationOverflowStrategy controls how annotations resolve overflow.

const (
	AnnotationOverflowAutomatic AnnotationOverflowStrategy = iota
	AnnotationOverflowFit
	AnnotationOverflowFitChart
	AnnotationOverflowFitPlot
	AnnotationOverflowPadScale
	AnnotationOverflowDisabled
)

type AnnotationPosition

type AnnotationPosition int32

AnnotationPosition controls where an annotation is attached.

const (
	AnnotationTop AnnotationPosition = iota
	AnnotationBottom
	AnnotationLeading
	AnnotationTrailing
	AnnotationOverlay
	AnnotationTopLeading
	AnnotationTopTrailing
	AnnotationBottomLeading
	AnnotationBottomTrailing
	AnnotationAutomatic
)

type AxisConfig

type AxisConfig struct {
	// contains filtered or unexported fields
}

AxisConfig configures chart axes.

func AxisMarks

func AxisMarks(opts ...AxisOption) AxisConfig

AxisMarks configures a visible axis.

type AxisLabelOption

type AxisLabelOption struct {
	// contains filtered or unexported fields
}

AxisLabelOption configures chart axis labels.

func AxisLabelAlignmentOption

func AxisLabelAlignmentOption(alignment LabelAlignment) AxisLabelOption

AxisLabelAlignmentOption sets the axis label alignment.

func AxisLabelPosition

func AxisLabelPosition(position AnnotationPosition) AxisLabelOption

AxisLabelPosition sets the axis label position.

func AxisLabelSpacing

func AxisLabelSpacing(spacing float64) AxisLabelOption

AxisLabelSpacing sets the axis label spacing.

type AxisOption

type AxisOption struct {
	// contains filtered or unexported fields
}

AxisOption configures an axis.

func AxisDateLabels

func AxisDateLabels(pattern string, centered bool) AxisOption

AxisDateLabels enables date labels using a limited format pattern such as "MMM", "MM/dd", or "HH:mm".

func AxisGridLines

func AxisGridLines() AxisOption

AxisGridLines enables grid lines.

func AxisGridLinesStyled

func AxisGridLinesStyled(style LineStyle, centered bool) AxisOption

AxisGridLinesStyled enables grid lines with styling.

func AxisLabels

func AxisLabels() AxisOption

AxisLabels enables default labels.

func AxisPositionOption

func AxisPositionOption(position AxisPosition) AxisOption

AxisPositionOption sets the axis position.

func AxisPresetOption

func AxisPresetOption(preset AxisPreset) AxisOption

AxisPresetOption sets the axis preset.

func AxisTickCount

func AxisTickCount(desiredCount int) AxisOption

AxisTickCount targets an approximate tick count using the framework's automatic placement.

func AxisTickMinimumStride

func AxisTickMinimumStride(minimumStride float64, desiredCount int) AxisOption

AxisTickMinimumStride targets automatic placement with a minimum stride.

func AxisTickStride

func AxisTickStride(step float64) AxisOption

AxisTickStride uses a fixed numeric stride.

func AxisTickStrideRounded

func AxisTickStrideRounded(step float64, roundLowerBound, roundUpperBound bool) AxisOption

AxisTickStrideRounded uses a fixed numeric stride with explicit bound rounding.

func AxisTickValues

func AxisTickValues(values ...Value) AxisOption

AxisTickValues uses an explicit ordered list of tick values.

func AxisTicks

func AxisTicks() AxisOption

AxisTicks enables ticks.

func AxisTicksStyled

func AxisTicksStyled(length AxisTickLength, style LineStyle, centered bool) AxisOption

AxisTicksStyled enables ticks with styling.

func AxisValueLabels

func AxisValueLabels(format ValueFormat) AxisOption

AxisValueLabels enables numeric labels with an explicit formatter.

func AxisValuesOption

func AxisValuesOption(values AxisValues) AxisOption

AxisValuesOption sets the axis values configuration.

type AxisPosition

type AxisPosition int32

AxisPosition controls where an axis is drawn.

const (
	AxisPositionAutomatic AxisPosition = iota
	AxisPositionBottom
	AxisPositionTop
	AxisPositionLeading
	AxisPositionTrailing
)

type AxisPreset

type AxisPreset int32

AxisPreset controls the preset used for axis marks.

const (
	AxisPresetAutomatic AxisPreset = iota
	AxisPresetAligned
	AxisPresetExtended
	AxisPresetInset
)

type AxisStyleOption

type AxisStyleOption struct {
	// contains filtered or unexported fields
}

AxisStyleOption configures axis-content styling for chartXAxisStyle/chartYAxisStyle.

func AxisStyleBackgroundColor

func AxisStyleBackgroundColor(color swiftui.Color) AxisStyleOption

AxisStyleBackgroundColor applies a background color behind axis content.

func AxisStyleBackgroundView

func AxisStyleBackgroundView(view swiftui.View) AxisStyleOption

AxisStyleBackgroundView places a SwiftUI view behind axis content.

func AxisStyleForeground

func AxisStyleForeground(color swiftui.Color) AxisStyleOption

AxisStyleForeground applies a foreground style to axis content.

func AxisStyleOpacity

func AxisStyleOpacity(opacity float64) AxisStyleOption

AxisStyleOpacity applies opacity to axis content.

func AxisStyleOverlayView

func AxisStyleOverlayView(view swiftui.View) AxisStyleOption

AxisStyleOverlayView places a SwiftUI view over axis content.

type AxisTickLength

type AxisTickLength struct {
	// contains filtered or unexported fields
}

AxisTickLength controls native tick length behavior.

func AxisTickLengthLabel

func AxisTickLengthLabel(extendPastBy float64) AxisTickLength

AxisTickLengthLabel matches the current label length.

func AxisTickLengthLongestLabel

func AxisTickLengthLongestLabel(extendPastBy float64) AxisTickLength

AxisTickLengthLongestLabel matches the longest visible label length.

type AxisValues

type AxisValues struct {
	// contains filtered or unexported fields
}

AxisValues controls which ticks are emitted.

func AutomaticAxisValues

func AutomaticAxisValues() AxisValues

AutomaticAxisValues uses the framework default tick placement.

func AutomaticAxisValuesCount

func AutomaticAxisValuesCount(desiredCount int) AxisValues

AutomaticAxisValuesCount uses automatic placement with a desired tick count.

func AutomaticAxisValuesMinimumStride

func AutomaticAxisValuesMinimumStride(minimumStride float64, desiredCount int) AxisValues

AutomaticAxisValuesMinimumStride uses automatic placement with a minimum stride.

func AxisValueList

func AxisValueList(values ...Value) AxisValues

AxisValueList uses an explicit ordered list of tick values.

func NumericStride

func NumericStride(step float64) AxisValues

NumericStride uses a numeric stride.

func NumericStrideRounded

func NumericStrideRounded(step float64, roundLowerBound, roundUpperBound bool) AxisValues

NumericStrideRounded uses a numeric stride with explicit rounding.

func TimeStride

func TimeStride(unit TimeUnit) AxisValues

TimeStride uses a calendar-based stride.

func TimeStrideCount

func TimeStrideCount(unit TimeUnit, count int) AxisValues

TimeStrideCount uses a calendar-based stride with an explicit count.

func TimeStrideRounded

func TimeStrideRounded(unit TimeUnit, count int, roundLowerBound, roundUpperBound bool) AxisValues

TimeStrideRounded uses a calendar-based stride with an explicit count and rounding.

type ChartView

type ChartView struct {
	// contains filtered or unexported fields
}

ChartView is a lazily-built Charts view.

func Chart

func Chart(marks ...Mark) ChartView

Chart creates a chart from marks.

func (ChartView) AsView

func (c ChartView) AsView() swiftui.View

AsView returns the underlying SwiftUI view.

func (ChartView) ChartAngleSelection

func (c ChartView) ChartAngleSelection(binding SelectionValueBinding) ChartView

func (ChartView) ChartBackground

func (c ChartView) ChartBackground(background ProxyBackground) ChartView

func (ChartView) ChartForegroundStyleScale

func (c ChartView) ChartForegroundStyleScale(entries ...StyleScaleEntry) ChartView

ChartForegroundStyleScale configures a categorical foreground-style scale.

func (ChartView) ChartForegroundStyleScaleType

func (c ChartView) ChartForegroundStyleScaleType(scaleType ScaleType) ChartView

ChartForegroundStyleScaleType sets the foreground-style scale type.

func (ChartView) ChartGesture

func (c ChartView) ChartGesture(gesture ProxyGesture) ChartView

func (ChartView) ChartLegend

func (c ChartView) ChartLegend(config LegendConfig) ChartView

ChartLegend configures legend visibility and placement.

func (ChartView) ChartLineStyleScale

func (c ChartView) ChartLineStyleScale(entries ...LineStyleScaleEntry) ChartView

ChartLineStyleScale configures a categorical line-style scale.

func (ChartView) ChartOverlay

func (c ChartView) ChartOverlay(overlay ProxyOverlay) ChartView

func (ChartView) ChartPlotStyle

func (c ChartView) ChartPlotStyle(opts ...PlotStyleOption) ChartView

ChartPlotStyle configures the plot area.

func (ChartView) ChartScrollPositionInitialXDate

func (c ChartView) ChartScrollPositionInitialXDate(value time.Time) ChartView

ChartScrollPositionInitialXDate sets the initial time-based scroll position.

func (ChartView) ChartScrollPositionInitialXNumber

func (c ChartView) ChartScrollPositionInitialXNumber(value float64) ChartView

ChartScrollPositionInitialXNumber sets the initial numeric scroll position.

func (ChartView) ChartScrollPositionInitialYDate

func (c ChartView) ChartScrollPositionInitialYDate(value time.Time) ChartView

ChartScrollPositionInitialYDate sets the initial time-based y scroll position.

func (ChartView) ChartScrollPositionInitialYNumber

func (c ChartView) ChartScrollPositionInitialYNumber(value float64) ChartView

ChartScrollPositionInitialYNumber sets the initial numeric y scroll position.

func (ChartView) ChartScrollPositionX

func (c ChartView) ChartScrollPositionX(binding ScrollPositionBinding) ChartView

func (ChartView) ChartScrollPositionY

func (c ChartView) ChartScrollPositionY(binding ScrollPositionBinding) ChartView

func (ChartView) ChartScrollTargetBehavior

func (c ChartView) ChartScrollTargetBehavior(behavior ScrollTargetBehavior) ChartView

func (ChartView) ChartScrollableAxes

func (c ChartView) ChartScrollableAxes(axis ScrollAxis) ChartView

ChartScrollableAxes enables scrolling along the selected axes.

func (ChartView) ChartSymbolScale

func (c ChartView) ChartSymbolScale(entries ...SymbolScaleEntry) ChartView

ChartSymbolScale configures a categorical symbol scale.

func (ChartView) ChartSymbolSizeScale

func (c ChartView) ChartSymbolSizeScale(entries ...SymbolSizeScaleEntry) ChartView

ChartSymbolSizeScale configures a categorical symbol-size scale.

func (ChartView) ChartSymbolSizeScaleType

func (c ChartView) ChartSymbolSizeScaleType(scaleType ScaleType) ChartView

ChartSymbolSizeScaleType sets the symbol-size scale type.

func (ChartView) ChartXAxis

func (c ChartView) ChartXAxis(config AxisConfig) ChartView

ChartXAxis configures the x axis.

func (ChartView) ChartXAxisLabel

func (c ChartView) ChartXAxisLabel(text string, opts ...AxisLabelOption) ChartView

ChartXAxisLabel sets the x-axis label.

func (ChartView) ChartXAxisStyle

func (c ChartView) ChartXAxisStyle(opts ...AxisStyleOption) ChartView

ChartXAxisStyle styles x-axis content using a practical subset of chartXAxisStyle.

func (ChartView) ChartXScaleDomain

func (c ChartView) ChartXScaleDomain(domain Domain) ChartView

ChartXScaleDomain sets the x-axis scale domain.

func (ChartView) ChartXScaleRange

func (c ChartView) ChartXScaleRange(rng PositionScaleRange) ChartView

ChartXScaleRange sets the x-axis scale range.

func (ChartView) ChartXScaleType

func (c ChartView) ChartXScaleType(scaleType ScaleType) ChartView

ChartXScaleType sets the x-axis scale type.

func (ChartView) ChartXSelection

func (c ChartView) ChartXSelection(binding SelectionValueBinding) ChartView

func (ChartView) ChartXSelectionRange

func (c ChartView) ChartXSelectionRange(binding SelectionRangeBinding) ChartView

func (ChartView) ChartXVisibleDomain

func (c ChartView) ChartXVisibleDomain(length visibleDomainLength) ChartView

func (ChartView) ChartXVisibleDomainLength

func (c ChartView) ChartXVisibleDomainLength(length float64) ChartView

ChartXVisibleDomainLength sets the visible x-domain length for scrollable charts.

For time-based charts, length is interpreted as seconds.

func (ChartView) ChartYAxis

func (c ChartView) ChartYAxis(config AxisConfig) ChartView

ChartYAxis configures the y axis.

func (ChartView) ChartYAxisLabel

func (c ChartView) ChartYAxisLabel(text string, opts ...AxisLabelOption) ChartView

ChartYAxisLabel sets the y-axis label.

func (ChartView) ChartYAxisStyle

func (c ChartView) ChartYAxisStyle(opts ...AxisStyleOption) ChartView

ChartYAxisStyle styles y-axis content using a practical subset of chartYAxisStyle.

func (ChartView) ChartYScaleDomain

func (c ChartView) ChartYScaleDomain(domain Domain) ChartView

ChartYScaleDomain sets the y-axis scale domain.

func (ChartView) ChartYScaleRange

func (c ChartView) ChartYScaleRange(rng PositionScaleRange) ChartView

ChartYScaleRange sets the y-axis scale range.

func (ChartView) ChartYScaleType

func (c ChartView) ChartYScaleType(scaleType ScaleType) ChartView

ChartYScaleType sets the y-axis scale type.

func (ChartView) ChartYSelection

func (c ChartView) ChartYSelection(binding SelectionValueBinding) ChartView

func (ChartView) ChartYSelectionRange

func (c ChartView) ChartYSelectionRange(binding SelectionRangeBinding) ChartView

func (ChartView) ChartYVisibleDomain

func (c ChartView) ChartYVisibleDomain(length visibleDomainLength) ChartView

func (ChartView) ChartYVisibleDomainLength

func (c ChartView) ChartYVisibleDomainLength(length float64) ChartView

ChartYVisibleDomainLength sets the visible y-domain length for scrollable charts.

For time-based charts, length is interpreted as seconds.

func (ChartView) Frame

func (c ChartView) Frame(width, height float64) swiftui.View

Frame applies a SwiftUI frame to the built chart view.

func (ChartView) Pointer

func (c ChartView) Pointer() uintptr

Pointer returns the underlying Swift pointer.

func (ChartView) View

func (c ChartView) View() swiftui.View

View returns the underlying SwiftUI view.

type DateComponents

type DateComponents struct {
	Year   int
	Month  int
	Day    int
	Hour   int
	Minute int
	Second int
}

DateComponents is a narrow bridge for date-aligned scrolling.

func MatchTimeUnit

func MatchTimeUnit(unit TimeUnit, count int) DateComponents

MatchTimeUnit returns date components for common chart time strides.

type DateRangeState

type DateRangeState struct {
	// contains filtered or unexported fields
}

DateRangeState is a bindable time-based range selection state.

func NewDateRangeState

func NewDateRangeState(start, end time.Time, ok bool) *DateRangeState

func (*DateRangeState) Clear

func (s *DateRangeState) Clear()

func (*DateRangeState) Get

func (s *DateRangeState) Get() (time.Time, time.Time, bool)

func (*DateRangeState) Release

func (s *DateRangeState) Release()

func (*DateRangeState) Set

func (s *DateRangeState) Set(start, end time.Time)

type DateState

type DateState struct {
	// contains filtered or unexported fields
}

DateState is a bindable time-based chart state.

func NewDateState

func NewDateState(initial time.Time) *DateState

func (*DateState) Get

func (s *DateState) Get() time.Time

func (*DateState) Release

func (s *DateState) Release()

func (*DateState) Set

func (s *DateState) Set(v time.Time)

type Dim

type Dim struct {
	// contains filtered or unexported fields
}

Dim is a mark dimension or dimension-like argument.

func Angle

func Angle(v Value) Dim

Angle places a value on a sector mark's angle dimension.

func AngularInset

func AngularInset(points float64) Dim

AngularInset sets a sector mark angular inset in points.

func HeightFixed

func HeightFixed(points float64) Dim

HeightFixed sets a rectangle mark's height in points.

func InnerRadiusRatio

func InnerRadiusRatio(ratio float64) Dim

InnerRadiusRatio sets a sector mark inner radius ratio.

func LowerQuartile

func LowerQuartile(v Value) Dim

LowerQuartile sets the first quartile value used by helpers such as BoxPlotMark.

func Maximum

func Maximum(v Value) Dim

Maximum sets the maximum value used by helpers such as BoxPlotMark.

func Median

func Median(v Value) Dim

Median sets the median value used by helpers such as BoxPlotMark.

func Minimum

func Minimum(v Value) Dim

Minimum sets the minimum value used by helpers such as BoxPlotMark.

func Q1

func Q1(v Value) Dim

Q1 is shorthand for LowerQuartile.

func Q3

func Q3(v Value) Dim

Q3 is shorthand for UpperQuartile.

func UpperQuartile

func UpperQuartile(v Value) Dim

UpperQuartile sets the third quartile value used by helpers such as BoxPlotMark.

func WidthRatio

func WidthRatio(ratio float64) Dim

WidthRatio sets a rectangle or ranged bar width as a ratio of the slot width.

func X

func X(v Value) Dim

X places a value on the chart's x axis.

func XDate

func XDate(label string, value time.Time, unit TimeUnit) Dim

func XDateRange

func XDateRange(label string, start, end time.Time, unit TimeUnit) Dim

func XFloat

func XFloat(label string, value float64) Dim

func XFloatRange

func XFloatRange(label string, start, end float64) Dim

func XInt

func XInt(label string, value int) Dim

func XRange

func XRange(start, end Value) Dim

XRange creates an x interval, used by marks such as RectangleMark.

func XString

func XString(label, value string) Dim

func Y

func Y(v Value) Dim

Y places a value on the chart's y axis.

func YDate

func YDate(label string, value time.Time, unit TimeUnit) Dim

func YFloat

func YFloat(label string, value float64) Dim

func YFloatRange

func YFloatRange(label string, start, end float64) Dim

func YInt

func YInt(label string, value int) Dim

func YIntRange

func YIntRange(label string, start, end int) Dim

func YRange

func YRange(start, end Value) Dim

YRange creates a y interval, used by marks such as AreaMark, BarMark, and RectangleMark.

func YString

func YString(label, value string) Dim

type Domain

type Domain struct {
	// contains filtered or unexported fields
}

Domain is a chart scale domain.

func CategoryDomain

func CategoryDomain(values ...string) Domain

CategoryDomain creates an ordered categorical domain.

func IntegerDomain

func IntegerDomain(min, max int) Domain

IntegerDomain creates an integer domain.

func NumberDomain

func NumberDomain(min, max float64) Domain

NumberDomain creates a floating-point domain.

func TimeDomain

func TimeDomain(start, end time.Time) Domain

TimeDomain creates a time domain.

type DurationUnit

type DurationUnit int32

DurationUnit controls duration-oriented numeric formatting.

const (
	DurationUnitSecond DurationUnit = iota
	DurationUnitMillisecond
	DurationUnitMicrosecond
	DurationUnitNanosecond
	DurationUnitMinute
)

type InterpolationMethod

type InterpolationMethod struct {
	// contains filtered or unexported fields
}

InterpolationMethod controls line and area interpolation.

func InterpolationCardinalTension

func InterpolationCardinalTension(tension float64) InterpolationMethod

InterpolationCardinalTension returns a cardinal interpolation with an explicit tension.

func InterpolationCatmullRomAlpha

func InterpolationCatmullRomAlpha(alpha float64) InterpolationMethod

InterpolationCatmullRomAlpha returns a Catmull-Rom interpolation with an explicit alpha.

type LabelAlignment

type LabelAlignment int32

LabelAlignment controls label alignment for axis labels.

const (
	LabelAlignmentCenter LabelAlignment = iota
	LabelAlignmentLeading
	LabelAlignmentTrailing
	LabelAlignmentTop
	LabelAlignmentBottom
	LabelAlignmentTopLeading
	LabelAlignmentTopTrailing
	LabelAlignmentBottomLeading
	LabelAlignmentBottomTrailing
)

type LegendAlignment

type LegendAlignment int32

LegendAlignment controls legend alignment.

const (
	LegendAlignmentCenter LegendAlignment = iota
	LegendAlignmentLeading
	LegendAlignmentTrailing
	LegendAlignmentTop
	LegendAlignmentBottom
)

type LegendConfig

type LegendConfig struct {
	Visibility LegendVisibility
	Position   LegendPosition
	Alignment  LegendAlignment
	Spacing    float64
}

LegendConfig configures the chart legend.

func LegendCompact

func LegendCompact(position LegendPosition, alignment LegendAlignment) LegendConfig

LegendCompact returns a visible legend tuned for dense short series labels.

func LegendVisible

func LegendVisible(position LegendPosition, alignment LegendAlignment, spacing float64) LegendConfig

LegendVisible returns a visible legend configuration.

type LegendPosition

type LegendPosition int32

LegendPosition controls legend placement.

const (
	LegendPositionAutomatic LegendPosition = iota
	LegendPositionTop
	LegendPositionBottom
	LegendPositionLeading
	LegendPositionTrailing
	LegendPositionOverlay
)

type LegendVisibility

type LegendVisibility int32

LegendVisibility controls legend visibility.

const (
	LegendVisibilityAutomatic LegendVisibility = iota
	LegendVisibilityVisible
	LegendVisibilityHidden
)

type LineStyle

type LineStyle struct {
	Width float64
	Dash  []float64
}

LineStyle controls stroke width and dash pattern.

func Stroke

func Stroke(width float64, dash ...float64) LineStyle

Stroke creates a line style.

type LineStyleScaleEntry

type LineStyleScaleEntry struct {
	Key   string
	Style LineStyle
}

LineStyleScaleEntry maps a series key to a line style.

func LineStyleScale

func LineStyleScale(key string, style LineStyle) LineStyleScaleEntry

LineStyleScale creates a categorical line-style scale entry.

type MajorValueAlignment

type MajorValueAlignment struct {
	// contains filtered or unexported fields
}

MajorValueAlignment controls how value-aligned scrolling snaps to larger boundaries.

func MajorValueAlignmentMatching

func MajorValueAlignmentMatching(components DateComponents) MajorValueAlignment

func MajorValueAlignmentUnit

func MajorValueAlignmentUnit(unit float64) MajorValueAlignment

type Mark

type Mark struct {
	// contains filtered or unexported fields
}

Mark is a chart mark or a mark group.

func AreaMark

func AreaMark(dims ...Dim) Mark

AreaMark creates an area mark.

func BarMark

func BarMark(dims ...Dim) Mark

BarMark creates a bar mark.

func BoxPlotMark

func BoxPlotMark(dims ...Dim) Mark

BoxPlotMark creates a box plot from min/q1/median/q3/max values.

func ErrorBarMark

func ErrorBarMark(dims ...Dim) Mark

ErrorBarMark creates a whisker-style interval mark.

func LineMark

func LineMark(dims ...Dim) Mark

LineMark creates a line mark.

func MapPointPlot

func MapPointPlot[T any](data []T, x func(T) Value, y func(T) Value) Mark

MapPointPlot maps a Go slice into a vectorized point plot.

func MapRectanglePlot

func MapRectanglePlot[T any](data []T, x func(T) Value, y func(T) Value, width, height MarkDimension) Mark

MapRectanglePlot maps a Go slice into a vectorized centered rectangle plot.

func MapRulePlot

func MapRulePlot[T any](data []T, xStart func(T) Value, xEnd func(T) Value, y func(T) Value) Mark

MapRulePlot maps a Go slice into a vectorized ranged rule plot.

func MarkGroup

func MarkGroup(marks ...Mark) Mark

MarkGroup groups marks without adding series semantics.

func PointMark

func PointMark(dims ...Dim) Mark

PointMark creates a point mark.

func PointPlot

func PointPlot(data ...PointPlotDatum) Mark

PointPlot creates a vectorized point plot.

func RangeBarMark

func RangeBarMark(dims ...Dim) Mark

RangeBarMark creates a horizontal or vertical interval bar.

func RectangleMark

func RectangleMark(dims ...Dim) Mark

RectangleMark creates a rectangle mark.

func RectanglePlot

func RectanglePlot(data ...RectanglePlotDatum) Mark

RectanglePlot creates a vectorized rectangle plot.

func ReferenceLineX

func ReferenceLineX(value Value, label string) Mark

ReferenceLineX creates a labeled x-axis reference line.

func ReferenceLineY

func ReferenceLineY(value Value, label string) Mark

ReferenceLineY creates a labeled y-axis reference line.

func RuleMark

func RuleMark(dims ...Dim) Mark

RuleMark creates a rule mark.

func RulePlot

func RulePlot(data ...RulePlotDatum) Mark

RulePlot creates a vectorized rule plot.

func SectorMark

func SectorMark(dims ...Dim) Mark

SectorMark creates a sector mark.

func Series

func Series(marks ...Mark) Mark

Series groups marks that conceptually belong to one series.

func (Mark) AccessibilityHidden

func (m Mark) AccessibilityHidden(hidden bool) Mark

AccessibilityHidden hides a mark from accessibility.

func (Mark) AccessibilityLabel

func (m Mark) AccessibilityLabel(text string) Mark

AccessibilityLabel sets a mark accessibility label.

func (Mark) AccessibilityValue

func (m Mark) AccessibilityValue(text string) Mark

AccessibilityValue sets a mark accessibility value description.

func (Mark) AlignsMarkStylesWithPlotArea

func (m Mark) AlignsMarkStylesWithPlotArea(aligns bool) Mark

AlignsMarkStylesWithPlotArea aligns mark styles with the plot area.

func (Mark) Annotation

func (m Mark) Annotation(position AnnotationPosition, alignment AnnotationAlignment, content swiftui.View) Mark

Annotation attaches a SwiftUI view annotation to the mark.

func (Mark) AnnotationCollision

func (m Mark) AnnotationCollision(mode AnnotationCollisionMode) Mark

AnnotationCollision applies a built-in collision policy for nearby annotations.

func (Mark) AnnotationDeclutterByDistance

func (m Mark) AnnotationDeclutterByDistance(minX, minY float64) Mark

AnnotationDeclutterByDistance suppresses annotations on nearby sibling marks.

The heuristic runs in chart data space, with latest marks winning ties. Numeric and time axes use their underlying values. Categorical axes use stable ordinal positions within the sibling sequence.

func (Mark) AnnotationDeclutterLatest

func (m Mark) AnnotationDeclutterLatest(maxCount int) Mark

AnnotationDeclutterLatest keeps annotations on only the most recent marks in a sibling sequence.

func (Mark) AnnotationOffset

func (m Mark) AnnotationOffset(x, y float64) Mark

AnnotationOffset offsets an annotation view in points after attachment.

func (Mark) AnnotationOffsetChart

func (m Mark) AnnotationOffsetChart(dx, dy float64) Mark

AnnotationOffsetChart offsets an annotation anchor in chart data space.

This is intended for numeric and time axes. Unsupported axes leave the mark unchanged.

func (Mark) AnnotationOverflow

func (m Mark) AnnotationOverflow(x, y AnnotationOverflowStrategy) Mark

AnnotationOverflow sets overflow handling for mark annotations.

func (Mark) AnnotationPriority

func (m Mark) AnnotationPriority(priority int) Mark

AnnotationPriority prefers this annotation when using AnnotationCollisionKeepPriority.

func (Mark) Blur

func (m Mark) Blur(radius float64) Mark

Blur applies a blur radius to the mark.

func (Mark) CornerRadius

func (m Mark) CornerRadius(radius float64) Mark

CornerRadius sets a corner radius for supported marks.

func (Mark) ExcludeFromLegend

func (m Mark) ExcludeFromLegend() Mark

ExcludeFromLegend resolves style-scale-backed mark styling to fixed values when possible.

func (Mark) ForegroundStyle

func (m Mark) ForegroundStyle(color swiftui.Color) Mark

ForegroundStyle sets a fixed mark color.

func (Mark) ForegroundStyleBy

func (m Mark) ForegroundStyleBy(label, value string) Mark

ForegroundStyleBy assigns a categorical style key, typically producing a legend.

func (Mark) Interpolation

func (m Mark) Interpolation(method InterpolationMethod) Mark

Interpolation sets the interpolation method for line and area marks.

func (Mark) LineStyle

func (m Mark) LineStyle(style LineStyle) Mark

LineStyle sets a stroke style for line-like marks.

func (Mark) LineStyleBy

func (m Mark) LineStyleBy(label, value string) Mark

LineStyleBy assigns line styles by category.

func (Mark) Offset

func (m Mark) Offset(x, y float64) Mark

Offset offsets the rendered mark by the provided amounts.

func (Mark) Opacity

func (m Mark) Opacity(opacity float64) Mark

Opacity sets mark opacity.

func (Mark) PositionBy

func (m Mark) PositionBy(label, value string) Mark

PositionBy groups marks by category for side-by-side placement.

func (Mark) Shadow

func (m Mark) Shadow(color swiftui.Color, radius, x, y float64) Mark

Shadow applies a shadow to the mark.

func (Mark) Stacking

func (m Mark) Stacking(stacking MarkStacking) Mark

Stacking sets bar or area stacking behavior.

func (Mark) Symbol

func (m Mark) Symbol(symbol SymbolKind) Mark

Symbol sets a fixed symbol shape.

func (Mark) SymbolBy

func (m Mark) SymbolBy(label, value string) Mark

SymbolBy assigns symbols by category.

func (Mark) SymbolDiameter

func (m Mark) SymbolDiameter(points float64) Mark

SymbolDiameter sets the symbol size using a visual diameter in points.

func (Mark) SymbolRadius

func (m Mark) SymbolRadius(points float64) Mark

SymbolRadius sets the symbol size using a visual radius in points.

func (Mark) SymbolSize

func (m Mark) SymbolSize(area float64) Mark

SymbolSize sets the symbol area in square points.

func (Mark) SymbolSizeBy

func (m Mark) SymbolSizeBy(label, value string) Mark

SymbolSizeBy assigns symbol sizes by category.

func (Mark) SymbolStroke

func (m Mark) SymbolStroke(color swiftui.Color, width float64) Mark

SymbolStroke draws a contrasting outline around a fixed symbol.

func (Mark) TextAnnotation

func (m Mark) TextAnnotation(text string, position AnnotationPosition) Mark

TextAnnotation attaches a lightweight text label to the mark.

func (Mark) TextAnnotationAligned

func (m Mark) TextAnnotationAligned(text string, position AnnotationPosition, alignment AnnotationAlignment) Mark

TextAnnotationAligned attaches a lightweight text label with explicit alignment.

func (Mark) ZIndex

func (m Mark) ZIndex(value float64) Mark

ZIndex sets the z-index for mark rendering order.

type MarkDimension

type MarkDimension struct {
	// contains filtered or unexported fields
}

MarkDimension configures vectorized rectangle sizing.

func MarkDimensionFixed

func MarkDimensionFixed(points float64) MarkDimension

MarkDimensionFixed uses a fixed size in points.

func MarkDimensionInset

func MarkDimensionInset(inset float64) MarkDimension

MarkDimensionInset uses an inset relative to the slot.

func MarkDimensionRatio

func MarkDimensionRatio(ratio float64) MarkDimension

MarkDimensionRatio uses a slot-relative size ratio.

type MarkStacking

type MarkStacking int32

MarkStacking controls bar and area stacking behavior.

const (
	MarkStackingAutomatic MarkStacking = iota
	MarkStackingStandard
	MarkStackingCentered
	MarkStackingNormalized
	MarkStackingUnstacked
)

type NumberRangeState

type NumberRangeState struct {
	// contains filtered or unexported fields
}

NumberRangeState is a bindable numeric range selection state.

func NewNumberRangeState

func NewNumberRangeState(start, end float64, ok bool) *NumberRangeState

func (*NumberRangeState) Clear

func (s *NumberRangeState) Clear()

func (*NumberRangeState) Get

func (s *NumberRangeState) Get() (float64, float64, bool)

func (*NumberRangeState) Release

func (s *NumberRangeState) Release()

func (*NumberRangeState) Set

func (s *NumberRangeState) Set(start, end float64)

type NumberState

type NumberState struct {
	// contains filtered or unexported fields
}

NumberState is a bindable numeric chart state.

func NewNumberState

func NewNumberState(initial float64) *NumberState

func (*NumberState) Get

func (s *NumberState) Get() float64

func (*NumberState) Release

func (s *NumberState) Release()

func (*NumberState) Set

func (s *NumberState) Set(v float64)

type OptionalDateState

type OptionalDateState struct {
	// contains filtered or unexported fields
}

OptionalDateState is a bindable optional time-based selection state.

func NewOptionalDateState

func NewOptionalDateState(initial time.Time, ok bool) *OptionalDateState

func (*OptionalDateState) Clear

func (s *OptionalDateState) Clear()

func (*OptionalDateState) Get

func (s *OptionalDateState) Get() (time.Time, bool)

func (*OptionalDateState) Release

func (s *OptionalDateState) Release()

func (*OptionalDateState) Set

func (s *OptionalDateState) Set(v time.Time)

type OptionalNumberState

type OptionalNumberState struct {
	// contains filtered or unexported fields
}

OptionalNumberState is a bindable optional numeric selection state.

func NewOptionalNumberState

func NewOptionalNumberState(initial float64, ok bool) *OptionalNumberState

func (*OptionalNumberState) Clear

func (s *OptionalNumberState) Clear()

func (*OptionalNumberState) Get

func (s *OptionalNumberState) Get() (float64, bool)

func (*OptionalNumberState) Release

func (s *OptionalNumberState) Release()

func (*OptionalNumberState) Set

func (s *OptionalNumberState) Set(v float64)

type PlotStyleOption

type PlotStyleOption struct {
	// contains filtered or unexported fields
}

PlotStyleOption configures the chart plot area.

func PlotBackgroundColor

func PlotBackgroundColor(color swiftui.Color) PlotStyleOption

PlotBackgroundColor sets a solid plot-area background color.

func PlotBackgroundView

func PlotBackgroundView(view swiftui.View) PlotStyleOption

PlotBackgroundView places a SwiftUI view behind the plot area.

func PlotBorder

func PlotBorder(color swiftui.Color, width float64) PlotStyleOption

PlotBorder draws a border around the plot area.

func PlotInset

func PlotInset(top, right, bottom, left float64) PlotStyleOption

PlotInset adds plot-area padding in points.

func PlotInsetAll

func PlotInsetAll(padding float64) PlotStyleOption

PlotInsetAll adds equal plot-area padding on every edge in points.

func PlotOverlayView

func PlotOverlayView(view swiftui.View) PlotStyleOption

PlotOverlayView places a SwiftUI view over the plot area.

type PointPlotDatum

type PointPlotDatum struct {
	X Value
	Y Value
}

PointPlotDatum is one point in a vectorized point plot.

func PlotPoint

func PlotPoint(x, y Value) PointPlotDatum

PlotPoint creates a vectorized point plot datum.

type PositionScaleRange

type PositionScaleRange struct {
	// contains filtered or unexported fields
}

PositionScaleRange controls a native positional scale range.

func PlotDimensionRange

func PlotDimensionRange(startPadding, endPadding float64) PositionScaleRange

PlotDimensionRange uses the plot dimension with optional start and end padding.

type ProxyBackground

type ProxyBackground struct {
	// contains filtered or unexported fields
}

ProxyBackground is a practical chart background driven by ChartProxy data.

func SelectionBandBackgroundX

func SelectionBandBackgroundX(r SelectionRangeBinding, color swiftui.Color) ProxyBackground

SelectionBandBackgroundX shows the selected x-range behind the plot.

func SelectionBandBackgroundY

func SelectionBandBackgroundY(r SelectionRangeBinding, color swiftui.Color) ProxyBackground

SelectionBandBackgroundY shows the selected y-range behind the plot.

type ProxyGesture

type ProxyGesture struct {
	// contains filtered or unexported fields
}

ProxyGesture is a practical drag-selection gesture driven by ChartProxy.

func DragAngleSelectionGesture

func DragAngleSelectionGesture(state SelectionValueBinding, minDistance float64) ProxyGesture

func DragXRangeSelectionGesture

func DragXRangeSelectionGesture(state SelectionRangeBinding, minDistance float64) ProxyGesture

func DragXSelectionGesture

func DragXSelectionGesture(state SelectionValueBinding, minDistance float64) ProxyGesture

func DragYRangeSelectionGesture

func DragYRangeSelectionGesture(state SelectionRangeBinding, minDistance float64) ProxyGesture

func DragYSelectionGesture

func DragYSelectionGesture(state SelectionValueBinding, minDistance float64) ProxyGesture

type ProxyOverlay

type ProxyOverlay struct {
	// contains filtered or unexported fields
}

ProxyOverlay is a practical chart overlay driven by ChartProxy data.

func CrosshairOverlay

func CrosshairOverlay(x SelectionValueBinding, y SelectionValueBinding, color swiftui.Color, width float64) ProxyOverlay

CrosshairOverlay draws x/y crosshair guides from selection state.

func ReadoutOverlay

func ReadoutOverlay(x SelectionValueBinding, y SelectionValueBinding, alignment LabelAlignment, xFormat, yFormat ValueFormat) ProxyOverlay

ReadoutOverlay shows a compact hover/readout box from selection state.

type RectanglePlotDatum

type RectanglePlotDatum struct {
	X      *Value
	Y      *Value
	XStart *Value
	XEnd   *Value
	YStart *Value
	YEnd   *Value
	Width  MarkDimension
	Height MarkDimension
}

RectanglePlotDatum is one rectangle in a vectorized rectangle plot.

func PlotRectangleRange

func PlotRectangleRange(xStart, xEnd, yStart, yEnd Value) RectanglePlotDatum

PlotRectangleRange creates a fully-ranged rectangle datum.

func PlotRectangleXRange

func PlotRectangleXRange(xStart, xEnd, y Value, height MarkDimension) RectanglePlotDatum

PlotRectangleXRange creates a ranged-x rectangle datum.

func PlotRectangleXY

func PlotRectangleXY(x, y Value, width, height MarkDimension) RectanglePlotDatum

PlotRectangleXY creates a centered rectangle datum.

func PlotRectangleYRange

func PlotRectangleYRange(x, yStart, yEnd Value, width MarkDimension) RectanglePlotDatum

PlotRectangleYRange creates a ranged-y rectangle datum.

type RulePlotDatum

type RulePlotDatum struct {
	X      *Value
	Y      *Value
	XStart *Value
	XEnd   *Value
	YStart *Value
	YEnd   *Value
}

RulePlotDatum is one rule in a vectorized rule plot.

func PlotRuleXRange

func PlotRuleXRange(xStart, xEnd, y Value) RulePlotDatum

PlotRuleXRange creates an x-ranged rule datum.

func PlotRuleYRange

func PlotRuleYRange(x, yStart, yEnd Value) RulePlotDatum

PlotRuleYRange creates a y-ranged rule datum.

type ScaleType

type ScaleType struct {
	// contains filtered or unexported fields
}

ScaleType controls a chart axis scale type.

func ScaleTypePower

func ScaleTypePower(exponent float64) ScaleType

ScaleTypePower returns a power scale with the provided exponent.

func ScaleTypeSymmetricLog

func ScaleTypeSymmetricLog(slopeAtZero float64) ScaleType

ScaleTypeSymmetricLog returns a symmetric-log scale with the provided slope near zero.

type ScrollAxis

type ScrollAxis int32

ScrollAxis controls chart scrolling.

const (
	ScrollAxisNone ScrollAxis = iota
	ScrollAxisHorizontal
	ScrollAxisVertical
	ScrollAxisBoth
)

type ScrollPositionBinding

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

type ScrollTargetBehavior

type ScrollTargetBehavior struct {
	// contains filtered or unexported fields
}

ScrollTargetBehavior configures snapping for scrollable charts.

func DateAlignedScrollTarget

func DateAlignedScrollTarget(components DateComponents, major *MajorValueAlignment, limit ValueAlignedLimitBehavior) ScrollTargetBehavior

DateAlignedScrollTarget aligns scrolling to matching date components.

func DateAlignedXYScrollTarget

func DateAlignedXYScrollTarget(xDate, yDate DateComponents, xMajor, yMajor *MajorValueAlignment, limit ValueAlignedLimitBehavior) ScrollTargetBehavior

DateAlignedXYScrollTarget aligns both axes to date components.

func ValueAlignedScrollTarget

func ValueAlignedScrollTarget(unit float64, major *MajorValueAlignment, limit ValueAlignedLimitBehavior) ScrollTargetBehavior

ValueAlignedScrollTarget aligns scrolling to a numeric unit.

func ValueAlignedXYScrollTarget

func ValueAlignedXYScrollTarget(xUnit, yUnit float64, xMajor, yMajor *MajorValueAlignment, limit ValueAlignedLimitBehavior) ScrollTargetBehavior

ValueAlignedXYScrollTarget aligns both axes to numeric units.

type SelectionRangeBinding

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

type SelectionValueBinding

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

type StyleScaleEntry

type StyleScaleEntry struct {
	Key   string
	Color swiftui.Color
}

StyleScaleEntry maps a series key to a color.

func StyleScale

func StyleScale(key string, color swiftui.Color) StyleScaleEntry

StyleScale creates a categorical foreground-style scale entry.

type SymbolKind

type SymbolKind int32

SymbolKind controls a fixed symbol shape.

const (
	SymbolCircle SymbolKind = iota
	SymbolSquare
	SymbolDiamond
	SymbolTriangle
	SymbolPentagon
	SymbolPlus
	SymbolCross
	SymbolAsterisk
)

type SymbolScaleEntry

type SymbolScaleEntry struct {
	Key    string
	Symbol SymbolKind
}

SymbolScaleEntry maps a series key to a symbol shape.

func SymbolScale

func SymbolScale(key string, symbol SymbolKind) SymbolScaleEntry

SymbolScale creates a categorical symbol-scale entry.

type SymbolSizeScaleEntry

type SymbolSizeScaleEntry struct {
	Key  string
	Size float64
}

SymbolSizeScaleEntry maps a series key to a symbol size.

func SymbolSizeScale

func SymbolSizeScale(key string, size float64) SymbolSizeScaleEntry

SymbolSizeScale creates a categorical symbol-size scale entry.

type TimeUnit

type TimeUnit int32

TimeUnit controls date-based chart values and axis strides.

const (
	TimeUnitDay TimeUnit = iota
	TimeUnitWeek
	TimeUnitMonth
	TimeUnitYear
	TimeUnitHour
	TimeUnitMinute
)

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value is a labeled plottable value used by mark dimensions.

func CategoryValue

func CategoryValue(label, value string) Value

CategoryValue creates a categorical plottable value.

func IntegerValue

func IntegerValue(label string, value int) Value

IntegerValue creates an integer plottable value.

func NumberValue

func NumberValue(label string, value float64) Value

NumberValue creates a floating-point plottable value.

func TimeValue

func TimeValue(label string, value time.Time, unit TimeUnit) Value

TimeValue creates a time-based plottable value.

type ValueAlignedLimitBehavior

type ValueAlignedLimitBehavior int32
const (
	ValueAlignedLimitAutomatic ValueAlignedLimitBehavior = iota
	ValueAlignedLimitAlways
	ValueAlignedLimitNever
)

type ValueFormat

type ValueFormat struct {
	// contains filtered or unexported fields
}

ValueFormat controls numeric formatting for axis labels and exact-value annotations.

func CompactFormat

func CompactFormat(precision int) ValueFormat

CompactFormat formats a value using compact notation such as 1.2K or 4.6M.

func DurationFormat

func DurationFormat(unit DurationUnit, precision int) ValueFormat

DurationFormat formats a numeric value as a duration-like label in a fixed unit.

func FixedFormat

func FixedFormat(precision int) ValueFormat

FixedFormat formats a value with fixed fractional precision.

func PercentFormat

func PercentFormat(precision int) ValueFormat

PercentFormat formats a fractional value as a percentage.

func SuffixFormat

func SuffixFormat(suffix string, precision int) ValueFormat

SuffixFormat formats a value with fixed precision and a literal suffix.

func (ValueFormat) Format

func (f ValueFormat) Format(value float64) string

Format formats a numeric value using the configured rules.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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