Refactor to GenerateXAxisLabels and GenerateYAxisLabels method
MODIFY
WalletWasabi.Fluent/Controls/LineChart.cs
WalletWasabi.Fluent/Controls/LineChart.cs
@@ -170,8 +170,8 @@ namespace WalletWasabi.Fluent.Controls
SetStateAreaPoints(state);
- SetStateXAxisLabels(state);
- SetStateYAxisLabels(state);
+ SetStateXAxisLabels(state, XAxisLabels);
+ SetStateYAxisLabels(state, YAxisLabels);
SetStateXAxisCursor(state);
@@ -213,34 +213,45 @@ namespace WalletWasabi.Fluent.Controls
}
}
- private void SetStateXAxisLabels(LineChartState state)
+ private void SetStateXAxisLabels(LineChartState state, IList<string>? xAxisLabels)
{
- var xAxisLabels = XAxisLabels;
-
if (xAxisLabels is not null)
{
- if (xAxisLabels.Count <= 1)
- {
- state.XAxisLabelStep = double.NaN;
+ GenerateXAxisLabels(state, xAxisLabels);
}
else
{
- state.XAxisLabelStep = state.AreaWidth / (xAxisLabels.Count - 1);
+ AutoGenerateXAxisLabels(state);
+ }
}
- state.XAxisLabels = xAxisLabels.ToList();
+ private void SetStateYAxisLabels(LineChartState state, IList<string>? yAxisLabels)
+ {
+ if (yAxisLabels is not null)
+ {
+ GenerateYAxisLabels(state, yAxisLabels);
}
else
{
- AutoGenerateXAxisLabels(state);
+ AutoGenerateYAxisLabels(state);
}
}
- private void SetStateYAxisLabels(LineChartState state)
+ private void GenerateXAxisLabels(LineChartState state, IList<string> xAxisLabels)
+ {
+ if (xAxisLabels.Count <= 1)
{
- var yAxisLabels = YAxisLabels;
+ state.XAxisLabelStep = double.NaN;
+ }
+ else
+ {
+ state.XAxisLabelStep = state.AreaWidth / (xAxisLabels.Count - 1);
+ }
- if (yAxisLabels is not null)
+ state.XAxisLabels = xAxisLabels.ToList();
+ }
+
+ private void GenerateYAxisLabels(LineChartState state, IList<string> yAxisLabels)
{
if (yAxisLabels.Count <= 1)
{
@@ -253,11 +264,6 @@ namespace WalletWasabi.Fluent.Controls
state.YAxisLabels = yAxisLabels.ToList();
}
- else
- {
- AutoGenerateYAxisLabels(state);
- }
- }
private void AutoGenerateXAxisLabels(LineChartState state)
{

Refactor to GenerateXAxisLabels and GenerateYAxisLabels method