Use XAxisCurrentValueIndex for slider value
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
@@ -47,11 +47,13 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
[AutoNotify] private double[] _yAxisValues;
[AutoNotify] private string[] _xAxisLabels;
[AutoNotify] private double _xAxisCurrentValue = 36;
- [AutoNotify(SetterModifier = AccessModifier.Private)] private double _xAxisMinValue = 1;
- [AutoNotify(SetterModifier = AccessModifier.Private)] private double _xAxisMaxValue = 1008;
+ [AutoNotify] private int _xAxisCurrentValueIndex;
+ [AutoNotify(SetterModifier = AccessModifier.Private)] private int _xAxisMinValue = 0;
+ [AutoNotify(SetterModifier = AccessModifier.Private)] private int _xAxisMaxValue = 9;
private string? _payJoinEndPoint;
private bool _parsingUrl;
+ private bool _updatingCurrentValue;
public SendViewModel(WalletViewModel walletVm, TransactionBroadcaster broadcaster)
{
@@ -78,9 +80,35 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
if (x > 0)
{
_transactionInfo.FeeRate = new FeeRate(GetYAxisValueFromXAxisCurrentValue(x));
+
+ if (!_updatingCurrentValue)
+ {
+ _updatingCurrentValue = true;
+ if (_xAxisValues is not null)
+ {
+ XAxisCurrentValueIndex = GetCurrentValueIndex(x, _xAxisValues);
+ }
+ _updatingCurrentValue = false;
+ }
+ }
+ });
+
+ this.WhenAnyValue(x => x.XAxisCurrentValueIndex)
+ .Subscribe(x =>
+ {
+ if (_xAxisValues is not null)
+ {
+ if (!_updatingCurrentValue)
+ {
+ _updatingCurrentValue = true;
+ var index = _xAxisValues.Length - x - 1;
+ XAxisCurrentValue = _xAxisValues[index];
+ _updatingCurrentValue = false;
+ }
}
});
+
Labels.ToObservableChangeSet().Subscribe(x =>
{
_transactionInfo.Labels = new SmartLabel(_labels.ToArray());
@@ -366,12 +394,29 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
xAxisLabels = TestNetXAxisLabels;
}
+ _updatingCurrentValue = true;
XAxisLabels = xAxisLabels;
XAxisValues = xAxisValues;
YAxisValues = yAxisValues;
- XAxisMinValue = xAxisValues.Min();
- XAxisMaxValue = xAxisValues.Max();
+ XAxisMinValue = 0;
+ XAxisMaxValue = xAxisValues.Length - 1;
XAxisCurrentValue = Math.Clamp(XAxisCurrentValue, XAxisMinValue, XAxisMaxValue);
+ XAxisCurrentValueIndex = GetCurrentValueIndex(XAxisCurrentValue, XAxisValues);
+ _updatingCurrentValue = false;
+ }
+
+ private int GetCurrentValueIndex(double xAxisCurrentValue, double[] xAxisValues)
+ {
+ for (var i = 0; i < xAxisValues.Length; i++)
+ {
+ if (xAxisValues[i] <= xAxisCurrentValue)
+ {
+ var index = xAxisValues.Length - i - 1;
+ return index;
+ }
+ }
+
+ return 0;
}
private void GetSmoothValuesSubdivide(double[] xs, double[] ys, out List<double> ts, out List<double> xts)

MODIFY
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
Classes="cursor"
Minimum="{Binding XAxisMinValue}"
Maximum="{Binding XAxisMaxValue}"
- Value="{Binding #GradientLineChart.XAxisCurrentValue}" />
+ Value="{Binding XAxisCurrentValueIndex}">
+ </Slider>
<c:LineChart x:Name="GradientLineChart"
Classes="cursor border xAxisLabels yAxis yAxisTitle"
MinHeight="30"

Use XAxisCurrentValueIndex for slider value