Releases: DanielJamesTronca/SleepChartKit
v1.2.0
SleepChartKit v1.2.0
- Added a minimalist timeline style (SleepChartView(style: .minimal)) that renders SleepTimelineGraph without legends, dotted overlays, or axis chrome—perfect for lightweight embeds.
- Updated README with installation version bump (from: "1.2.0"), documentation for the minimal style, and refreshed feature list to highlight the new option.
- Extended unit suite to cover the new enum case and ensure the minimal style continues to instantiate correctly.
Quick usage reminder:
SleepChartView(
samples: sleepSamples,
style: .minimal
)
All tests: swift test (passes).
Full Changelog: v1.1.0...v1.2.0
v1.1.0: Circular Chart with Threshold Support
🎉 New Features
SleepCircularChartView
- New circular chart component with percentage-based sleep duration visualization
- Configurable threshold system - set custom sleep duration targets (default: 9 hours)
- Optional sun/moon icons - toggle sleep start/end indicators on/off
- Percentage-based arc filling - starts at 12 o'clock and fills clockwise based on sleep duration vs threshold
🔧 API Changes
New Parameters
thresholdHours: Double- Sleep duration threshold for percentage calculation (default: 9.0)showIcons: Bool- Display sun/moon icons at start/end of sleep arc (default: true)
Usage Examples
```swift
// Basic circular chart (9-hour threshold by default)
SleepCircularChartView(samples: sleepSamples)
// Custom threshold and styling
SleepCircularChartView(
samples: sleepSamples,
lineWidth: 20,
size: 200,
showIcons: false,
thresholdHours: 8.0
)
```
📚 Documentation
- Updated README with comprehensive circular chart documentation
- Added parameter descriptions and usage examples
- Updated architecture section with new components
🧪 Testing
- Added comprehensive test suite for circular chart functionality
- All existing tests continue to pass
- Verified Swift package compilation
💡 How it Works
If a user sleeps 7 hours with a 9-hour threshold, the circle fills 77.8% (7/9) of the way around, providing intuitive visual feedback on sleep goal progress.
Full Changelog: v1.0.0...v1.1.0
v1.0.0: Initial SleepChartKit Release
🎉 Initial Release
Welcome to SleepChartKit - A clean, lightweight SwiftUI package for displaying beautiful sleep stage visualizations with comprehensive HealthKit integration.
✨ Core Features
📊 Timeline Visualization
- Interactive sleep stage timeline with smooth stage transitions
- Canvas-based rendering for precise control and performance
- Time axis with clear labels showing sleep session duration
- Color-coded sleep stages with intuitive visual representation
🏥 HealthKit Integration
- Native HKCategorySample support with automatic conversion
- Direct HealthKit integration - no manual conversion needed
- Type-safe sleep stage mapping between HealthKit and SleepChartKit
- iOS 16+ optimized with backwards compatibility
🎨 Customization System
- Flexible color providers - define custom color schemes for sleep stages
- Localization support - configurable display names for internationalization
- Custom duration formatting - personalize how sleep durations are displayed
- Extensible architecture following SOLID principles
🏗️ Architecture
Core Components
- SleepChartView - Main timeline chart container
- SleepTimelineGraph - Timeline visualization with Canvas
- SleepTimeAxisView - Time labels and axis
- SleepLegendView - Sleep stage legend and duration summary
Data Models
- SleepSample - Represents a sleep period with stage, start, and end times
- SleepStage - Comprehensive enum covering all sleep stages
- TimeSpan - Time axis label generation
Services (Protocol-Based)
- SleepStageColorProvider - Customizable stage colors
- SleepStageDisplayNameProvider - Localized stage names
- DurationFormatter - Custom duration text formatting
- TimeSpanGenerator - Flexible time axis customization
📱 Platform Support
- iOS 15.0+
- macOS 12.0+
- watchOS 8.0+
- tvOS 15.0+
🚀 Quick Start
```swift
import SwiftUI
import SleepChartKit
struct ContentView: View {
let sleepSamples = [
SleepSample(stage: .asleepDeep, startDate: date1, endDate: date2),
SleepSample(stage: .asleepCore, startDate: date2, endDate: date3),
SleepSample(stage: .asleepREM, startDate: date3, endDate: date4)
]
var body: some View {
SleepChartView(samples: sleepSamples)
.padding()
}
}
```
HealthKit Integration
```swift
// Direct HealthKit integration (iOS 16+)
SleepChartView(healthKitSamples: healthKitSamples)
// Manual conversion
let sleepSamples = SleepSample.samples(from: healthKitSamples)
SleepChartView(samples: sleepSamples)
```
🎯 Sleep Stages Supported
- Awake - Periods of wakefulness during sleep
- REM Sleep - Rapid Eye Movement sleep phases
- Core/Light Sleep - Standard sleep stages
- Deep Sleep - Restorative deep sleep periods
- Unspecified Sleep - General sleep periods
- In Bed - Time spent in bed (intelligently filtered)
🧪 Quality Assurance
- Comprehensive test suite with full coverage
- Swift Package Manager ready
- Clean, documented code following Swift best practices
- Memory efficient with optimized rendering
This initial release provides a solid foundation for sleep data visualization in SwiftUI applications with excellent HealthKit integration and extensive customization options.