add an optional minimum to xaxis line chart.
MODIFY
WalletWasabi.Fluent/Controls/LineChart.Properties.cs
WalletWasabi.Fluent/Controls/LineChart.Properties.cs
+using System;
using System.Collections.Generic;
using Avalonia;
using Avalonia.Media;
@@ -50,6 +51,9 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<IList<double>?> XAxisValuesProperty =
AvaloniaProperty.Register<LineChart, IList<double>?>(nameof(XAxisValues));
+ public static readonly StyledProperty<double?> XAxisMinimumProperty =
+ AvaloniaProperty.Register<LineChart, double?>(nameof(XAxisMinimum));
+
public static readonly StyledProperty<bool> XAxisLogarithmicScaleProperty =
AvaloniaProperty.Register<LineChart, bool>(nameof(XAxisLogarithmicScale));
@@ -455,6 +459,12 @@ namespace WalletWasabi.Fluent.Controls
set => SetValue(XAxisValuesProperty, value);
}
+ public double? XAxisMinimum
+ {
+ get => GetValue(XAxisMinimumProperty);
+ set => SetValue(XAxisMinimumProperty, value);
+ }
+
public bool XAxisLogarithmicScale
{
get => GetValue(XAxisLogarithmicScaleProperty);

MODIFY
WalletWasabi.Fluent/Controls/LineChart.cs
WalletWasabi.Fluent/Controls/LineChart.cs
@@ -229,7 +229,7 @@ namespace WalletWasabi.Fluent.Controls
switch (XAxisPlotMode)
{
case AxisPlotMode.Normal:
- var min = xAxisValues.Min();
+ var min = XAxisMinimum ?? xAxisValues.Min();
var max = xAxisValues.Max();
var xAxisScaler = new StraightLineFormula();

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/Tiles/WalletBalanceChartTileViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/Tiles/WalletBalanceChartTileViewModel.cs
@@ -55,6 +55,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.Tiles
private readonly ReadOnlyObservableCollection<HistoryItemViewModel> _history;
[AutoNotify] private ObservableCollection<double> _yValues;
[AutoNotify] private ObservableCollection<double> _xValues;
+ [AutoNotify] private double? _xMinimum;
+
private TimeSpan _sampleTime;
private TimeSpan _sampleLimit;
@@ -113,8 +115,21 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.Tiles
});
}
+ private double? GetMinimum(TimeSpan limit)
+ {
+ var latest = _history.FirstOrDefault();
+
+ if (latest is { })
+ {
+ return (double) (latest.Date - limit).ToUnixTimeMilliseconds();
+ }
+
+ return null;
+ }
+
private void UpdateSample()
{
+ XMinimum = GetMinimum(_sampleLimit);
var values = _history.TimeSampleDataSet(x => x.Date, x => x.Balance, _sampleTime, _sampleLimit);
XValues.Clear();

MODIFY
WalletWasabi.Fluent/Views/Wallets/Home/Tiles/WalletBalanceChartTileView.axaml
WalletWasabi.Fluent/Views/Wallets/Home/Tiles/WalletBalanceChartTileView.axaml
</StackPanel>
<c:LineChart x:CompileBindings="True" x:DataType="vm:WalletBalanceChartTileViewModel" x:Name="GradientLineChart" DockPanel.Dock="Left" Margin="30"
Classes="area border xAxis xAxisLabels yAxis yAxisLabels"
+ XAxisMinimum="{Binding XMinimum}"
XAxisValues="{Binding XValues}"
YAxisValues="{Binding YValues}">
<c:LineChart.AreaFill>

add an optional minimum to xaxis line chart.