Allow viewing evolution chart for individual or multiple sources across categories

Adds multi-source selection to the evolution chart source filter.
Users can now tap multiple sources to compare their evolution side by side,
regardless of which category they belong to.

Fixes #24

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
alexandrev-tibco
2026-02-11 23:52:38 +01:00
parent 9d2ed68dcc
commit 0dac19b109
2 changed files with 20 additions and 6 deletions
@@ -86,6 +86,7 @@ class ChartsViewModel: ObservableObject {
@Published var selectedChartType: ChartType = .evolution
@Published var selectedCategory: Category?
@Published var selectedSource: InvestmentSource?
@Published var selectedSourceIds: Set<UUID> = []
@Published var selectedTimeRange: TimeRange = .year
@Published var selectedAccount: Account?
@Published var showAllAccounts = true
@@ -290,7 +291,12 @@ class ChartsViewModel: ObservableObject {
}
let sources: [InvestmentSource]
if let selectedSource {
if !selectedSourceIds.isEmpty {
sources = sourceRepository.sources.filter { source in
guard let id = source.id else { return false }
return selectedSourceIds.contains(id) && shouldIncludeSource(source)
}
} else if let selectedSource {
sources = sourceRepository.sources.filter { $0.id == selectedSource.id && shouldIncludeSource($0) }
} else if let category = category {
sources = sourceRepository.fetchSources(for: category).filter { shouldIncludeSource($0) }