bind chart data from table.
ADD
WalletWasabi.Fluent/ViewModels/Wallets/Home/Tiles/WalletBalanceChartTileViewModel.cs
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Reactive.Linq;
+using DynamicData;
+using DynamicData.Alias;
+using DynamicData.Binding;
+using NBitcoin;
+using ReactiveUI;
+using WalletWasabi.Fluent.ViewModels.Wallets.Home.History;
+
+namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.Tiles
+{
+ public partial class WalletBalanceChartTileViewModel : ViewModelBase
+ {
+ private readonly ReadOnlyObservableCollection<HistoryItemViewModel> _history;
+ private readonly ReadOnlyObservableCollection<double> _yValues;
+ private readonly ReadOnlyObservableCollection<double> _xValues;
+
+ public WalletBalanceChartTileViewModel(ReadOnlyObservableCollection<HistoryItemViewModel> history)
+ {
+ _history = history;
+
+ _history
+ .ToObservableChangeSet()
+ .Select(x => (double) x.Balance.ToDecimal(MoneyUnit.BTC))
+ .Reverse()
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Bind(out _yValues)
+ .DisposeMany()
+ .Subscribe();
+
+ _history
+ .ToObservableChangeSet()
+ .Select(x => (double) x.Date.ToUnixTimeSeconds())
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Bind(out _xValues)
+ .DisposeMany()
+ .Subscribe();
+ }
+
+ public ReadOnlyObservableCollection<double> YValues => _yValues;
+
+ public ReadOnlyObservableCollection<double> XValues => _xValues;
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
@@ -48,6 +48,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
History = new HistoryViewModel(wallet, uiConfig);
BalanceTile = new WalletBalanceTileViewModel(wallet);
+ BalanceChartTile = new WalletBalanceChartTileViewModel(History.Transactions);
WalletPieChart = new WalletPieChartTileViewModel(wallet);
}
@@ -59,6 +60,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
public WalletBalanceTileViewModel BalanceTile { get; }
+ public WalletBalanceChartTileViewModel BalanceChartTile { get; }
+
public WalletPieChartTileViewModel WalletPieChart { get; }
protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disposables)

MODIFY
WalletWasabi.Fluent/Views/Wallets/Home/Tiles/WalletBalanceChartTileView.axaml
WalletWasabi.Fluent/Views/Wallets/Home/Tiles/WalletBalanceChartTileView.axaml
xmlns:vm="using:WalletWasabi.Fluent.ViewModels.LineChartDemo"
mc:Ignorable="d" d:DesignWidth="620" d:DesignHeight="310"
x:Class="WalletWasabi.Fluent.Views.Wallets.Home.Tiles.WalletBalanceChartTileView">
- <UserControl.DataContext>
- <vm:XYLineChartViewModel/>
- </UserControl.DataContext>
<UserControl.Styles>
<!-- LineChart Area -->
<Style Selector="c|LineChart.area">
<c:LineChart x:Name="GradientLineChart" DockPanel.Dock="Left" Margin="30"
Classes="area border xAxis xAxisLabels yAxis yAxisLabels"
XAxisLabels="{Binding XAxisLabels}"
- XAxisValues="{Binding XAxisValues}"
- YAxisValues="{Binding YAxisValues}">
+ XAxisValues="{Binding XValues}"
+ YAxisValues="{Binding YValues}">
</c:LineChart>
</DockPanel>
</Border>

DELETE
WalletWasabi.Fluent/Views/Wallets/Home/Tiles/WalletBalanceChartTileViewModel.cs
-using System.Collections.Generic;
-using WalletWasabi.Fluent.ViewModels;
-
-namespace WalletWasabi.Fluent.Views.Wallets.Home.Tiles
-{
- public partial class WalletBalanceChartTileViewModel : ViewModelBase
- {
- public List<double> YValues { get; } = new()
- {
- 0.25, 0.34, 0.79, 0.98, 1.2, 0.75, 0.68, 1.57
- };
-
- public List<double> XValues { get; } = new()
- {
- 0.25, 0.34, 0.79, 0.98, 1.2, 0.75, 0.68, 1.57
- };
- }
-}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/Wallets/WalletView.axaml
WalletWasabi.Fluent/Views/Wallets/WalletView.axaml
<tiles:WalletPieChartTileView DataContext="{Binding WalletPieChart}" c:ResponsivePanel.ColumnSpan="1, 1, 1" c:ResponsivePanel.RowSpan="1, 1, 2" />
- <tiles:WalletBalanceChartTileView
+ <tiles:WalletBalanceChartTileView DataContext="{Binding BalanceChartTile}"
c:ResponsivePanel.ColumnSpan="1, 2, 2" c:ResponsivePanel.RowSpan="1, 2, 2" />
</c:ResponsivePanel>
<history:HistoryTable DataContext="{Binding History}" MaxWidth="1000"

bind chart data from table.