charts3d

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: 13 Imported by: 0

Documentation

Overview

Package charts3d provides Go bindings for the 3D portion of Apple's Charts framework.

The package is separate from github.com/tmc/swiftui/charts so the 2D API stays focused. It currently covers practical 3D chart construction: point, rule, and rectangle marks; surface plots; domains and scale types; axis labels; and camera pose and projection controls.

The package requires the macOS 26 Charts APIs.

Quick start

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

view := charts3d.Chart3D(
	charts3d.PointMark(
		charts3d.XFloat("Step", 1),
		charts3d.YFloat("Loss", 0.42),
		charts3d.ZFloat("Depth", 3),
	),
).View()

_ = view

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Chart3DPoseDefault = Chart3DPose{/* contains filtered or unexported fields */}
	Chart3DPoseFront   = Chart3DPose{/* contains filtered or unexported fields */}
	Chart3DPoseBack    = Chart3DPose{/* contains filtered or unexported fields */}
	Chart3DPoseTop     = Chart3DPose{/* contains filtered or unexported fields */}
	Chart3DPoseBottom  = Chart3DPose{/* contains filtered or unexported fields */}
	Chart3DPoseLeft    = Chart3DPose{/* contains filtered or unexported fields */}
	Chart3DPoseRight   = Chart3DPose{/* 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 */}
	ScaleTypeSquareRoot = ScaleType{/* contains filtered or unexported fields */}
)

Functions

This section is empty.

Types

type AnnotationPosition

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

type AxisLabelOption

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

func AxisLabelAlignment

func AxisLabelAlignment(alignment LabelAlignment) AxisLabelOption

func AxisLabelPosition

func AxisLabelPosition(position AnnotationPosition) AxisLabelOption

func AxisLabelSpacing

func AxisLabelSpacing(spacing float64) AxisLabelOption

type CameraProjection

type CameraProjection int32

CameraProjection controls the chart camera projection.

const (
	CameraProjectionAutomatic CameraProjection = iota
	CameraProjectionOrthographic
	CameraProjectionPerspective
)

type Chart3DPose

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

Chart3DPose controls the viewpoint of a 3D chart.

func CustomChart3DPose

func CustomChart3DPose(azimuthDegrees, inclinationDegrees float64) Chart3DPose

type Chart3DView

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

Chart3DView is a lazily-built 3D chart view.

func Chart3D

func Chart3D(marks ...Mark) Chart3DView

Chart3D creates a 3D chart from z-aware marks.

Example
package main

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

func main() {
	view := charts3d.Chart3D(
		charts3d.PointMark(
			charts3d.XFloat("Step", 1),
			charts3d.YFloat("Loss", 0.42),
			charts3d.ZFloat("Depth", 3),
		),
	).ChartZAxisLabel("Depth").View()

	_ = view
}

func (Chart3DView) AsView

func (c Chart3DView) AsView() swiftui.View

func (Chart3DView) Chart3DCameraProjection

func (c Chart3DView) Chart3DCameraProjection(projection CameraProjection) Chart3DView

func (Chart3DView) Chart3DPose

func (c Chart3DView) Chart3DPose(pose Chart3DPose) Chart3DView

func (Chart3DView) ChartXAxisLabel

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

func (Chart3DView) ChartXScaleDomain

func (c Chart3DView) ChartXScaleDomain(domain Domain) Chart3DView

func (Chart3DView) ChartXScaleType

func (c Chart3DView) ChartXScaleType(scaleType ScaleType) Chart3DView

func (Chart3DView) ChartYAxisLabel

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

func (Chart3DView) ChartYScaleDomain

func (c Chart3DView) ChartYScaleDomain(domain Domain) Chart3DView

func (Chart3DView) ChartYScaleType

func (c Chart3DView) ChartYScaleType(scaleType ScaleType) Chart3DView

func (Chart3DView) ChartZAxisLabel

func (c Chart3DView) ChartZAxisLabel(text string, opts ...AxisLabelOption) Chart3DView

func (Chart3DView) ChartZScaleDomain

func (c Chart3DView) ChartZScaleDomain(domain Domain) Chart3DView

func (Chart3DView) ChartZScaleType

func (c Chart3DView) ChartZScaleType(scaleType ScaleType) Chart3DView

func (Chart3DView) Frame

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

func (Chart3DView) Pointer

func (c Chart3DView) Pointer() uintptr

func (Chart3DView) Surface

func (c Chart3DView) Surface(surface SurfacePlotContent) Chart3DView

func (Chart3DView) View

func (c Chart3DView) View() swiftui.View

type Dim

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

func X

func X(v Value) Dim

func XDate

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

func XFloat

func XFloat(label string, value float64) Dim

func XInt

func XInt(label string, value int) Dim

func Y

func Y(v Value) Dim

func YFloat

func YFloat(label string, value float64) Dim

func YInt

func YInt(label string, value int) Dim

func Z

func Z(v Value) Dim

func ZFloat

func ZFloat(label string, value float64) Dim

func ZInt

func ZInt(label string, value int) Dim

type Domain

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

func IntegerDomain

func IntegerDomain(min, max int) Domain

func NumberDomain

func NumberDomain(min, max float64) Domain

func TimeDomain

func TimeDomain(start, end time.Time) Domain

type LabelAlignment

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

type Mark

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

func PointMark

func PointMark(dims ...Dim) Mark

func RectangleMark

func RectangleMark(dims ...Dim) Mark

func RuleMark

func RuleMark(dims ...Dim) Mark

func (Mark) ForegroundStyle

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

type ScaleType

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

func ScaleTypePower

func ScaleTypePower(exponent float64) ScaleType

func ScaleTypeSymmetricLog

func ScaleTypeSymmetricLog(slopeAtZero float64) ScaleType

type SurfacePlotContent

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

SurfacePlotContent is a bridged Swift Charts surface plot.

func SurfacePlot

func SurfacePlot(xLabel, yLabel, zLabel string, f func(x, z float64) float64) SurfacePlotContent

SurfacePlot creates a 3D surface plot from a Go callback.

type TimeUnit

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

type Value

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

func IntegerValue

func IntegerValue(label string, value int) Value

func NumberValue

func NumberValue(label string, value float64) Value

func TimeValue

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

Jump to

Keyboard shortcuts

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