Swift package · v0.1.0

KLCharts

Render grouped bar data with Swift Charts or Canvas.

Flat and dimensional SwiftUI bar charts with application-owned selection, formatting, colors, and navigation. Geometry and hit-testing helpers are available for tests.

Platforms
iOS 17+ · macOS 14+
Toolchain
Swift 6.0+
License
MIT
Dependencies
None

Functions

  • Flat and projected dimensional renderers
  • Selection, clear, viewpoint reset, and formatting callbacks
  • Dense-group horizontal expansion
  • Testable width and hit-radius helpers

Not included

It renders resolved data; it does not aggregate domain models, localize labels, select themes, store UI state, or navigate from a bar.

Install with SwiftPM

Package.swiftSwift
.package(url: "https://github.com/KoenLee1023/KLCharts.git", from: "0.1.0")

Usage

Integration exampleSwift
KLDimensionalBarChart(
    data: data,
    mode: mode,
    emptyText: "No data",
    selectedID: selectedID,
    onSelect: { selectedID = $0.id }
)
.frame(height: 300)
KLDimensionalBarChart

Keeps both renderers mounted and switches mode through opacity and hit testing.

KLDimensionalBarDatum

Separates stable group and series identity from resolved display values.

KLFlatBarChartLayout

Predicts horizontal canvas width without rendering a view.

Demo apps

Interaction Lab

Inspect selection, clearing, scrolling, viewpoint, and reset behavior.