data-visualization/DSBarChartWidget
DSBarChartWidget
data-visualizationCard with a title and a set of labeled vertical bars.
iOS 17+macOS 14+watchOS 10+tvOS 17+visionOS 1+
Purpose
Compare values across a small number of categories, such as sales per weekday or tickets per team.
Interactive Reference
Live showroom
Need the full visual surface?
Screenshots do not scale well across every component, state, and variant. For the real interactive reference, import the package and launch DSShowcaseRoot().
Best for exploring:
variants, states, categories, and real app examples in one place.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| titlereq | String | — | Card title. |
| subtitle | String? | nil | Secondary line under the title. |
| barsreq | [DSBarChartWidget.Bar] | — | Bars to draw. Each Bar has a label, value and color (default DSColor.primary). |
| showValues | Bool | true | Prints each value above its bar. |
Examples
Sales per weekday
Highlight the best day with a different color.
swift
DSBarChartWidget(
title: "Sales",
subtitle: "This week",
bars: [
.init(label: "Mon", value: 12),
.init(label: "Tue", value: 18),
.init(label: "Wed", value: 25, color: DSColor.success),
.init(label: "Thu", value: 16),
.init(label: "Fri", value: 21),
]
)