Skip to content

Commit

Permalink
Delete IValueConverterNS. Fix GridLine bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zenjia committed Jan 1, 2021
1 parent 44673c3 commit e77861d
Show file tree
Hide file tree
Showing 33 changed files with 925 additions and 492 deletions.
44 changes: 0 additions & 44 deletions CommonLib/Axis/AxisItem/AxisItemDrawingParam.cs

This file was deleted.

11 changes: 1 addition & 10 deletions CommonLib/Axis/AxisItem/IAxisItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ namespace MvvmCharting.Axis
{
public interface IAxisItem: IPlottable_1D
{
/// <summary>
/// Accept change of Axis placement
/// </summary>
/// <param name="newValue"></param>
void SetAxisPlacement(AxisPlacement newValue);
object DataContext { get; }

/// <summary>
/// Accept change of Axis <see cref="LabelTextConverter"/>
/// </summary>
/// <param name="newValue"></param>
void SetLabelTextConverter(IValueConverterNS newValue);
}
}
74 changes: 74 additions & 0 deletions CommonLib/Axis/CategoryAxisDrawingSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MvvmCharting.Common;

namespace MvvmCharting.Axis
{
public class CategoryAxisDrawingSettings : ICategoryAxisDrawingSettings
{


#region input values

public IList<object> PlottingItemValues { get; }

public double PlottingLength { get; }
#endregion

#region generated values

public double ActualTickInterval { get; }

public int ActualTickCount { get; }

#endregion

public CategoryAxisDrawingSettings(int tickInterval, IList<object> plottingItemValues, double plottingLength)
{
if (plottingItemValues == null)
{
return;
}

this.PlottingItemValues = plottingItemValues;


this.PlottingLength = plottingLength;

//calculated state:
this.ActualTickInterval = tickInterval;

this.ActualTickCount = (int)Math.Floor(plottingItemValues.Count / this.ActualTickInterval) + 1;
}


public override bool Equals(object obj)
{
var other = obj as CategoryAxisDrawingSettings;
if (other == null)
{
return false;
}

return this.PlottingLength.NearlyEqual(other.PlottingLength, 0.0001) &&
this.PlottingItemValues?.Count == other.PlottingItemValues?.Count &&
(this.PlottingItemValues != null && this.PlottingItemValues.SequenceEqual(other.PlottingItemValues)) &&
this.ActualTickCount == other.ActualTickCount &&
this.ActualTickInterval == other.ActualTickInterval;
}

public bool CanUpdateAxisItems()
{

return !this.PlottingLength.IsNaNOrZero() && !this.ActualTickInterval.IsNaNOrZero();
}

public bool CanUpdateAxisItemsCoordinate()
{
return !this.PlottingLength.IsNaNOrZero() && this.PlottingItemValues?.Count > 0;
}

}
}
18 changes: 0 additions & 18 deletions CommonLib/Axis/DefaultDoubleToAxisLabelTextConverter.cs

This file was deleted.

16 changes: 0 additions & 16 deletions CommonLib/Axis/DefaultObjectToAxisLabelTextConverter.cs

This file was deleted.

5 changes: 1 addition & 4 deletions CommonLib/Axis/IAxisNS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public interface IAxisNS
int TickCount { get; set; }


/// <summary>
/// User provided converters for convert value to the LabelText of an <see cref="IAxisItem"/>.
/// </summary>
IValueConverterNS LabelTextConverter { get; set; }

}
}
2 changes: 1 addition & 1 deletion CommonLib/Axis/IXAxisOwner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface IXAxisOwner : IAxisOwner
{


event Action<PlottingSettings> HorizontalSettingChanged;
event Action<PlottingSettingsBase> HorizontalSettingChanged;


}
Expand Down
2 changes: 1 addition & 1 deletion CommonLib/Axis/IYAxisOwner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public interface IYAxisOwner : IAxisOwner
{


event Action<PlottingSettings> VerticalSettingChanged;
event Action<PlottingSettingsBase> VerticalSettingChanged;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using MvvmCharting.Common;

namespace MvvmCharting.Axis
Expand All @@ -7,26 +8,27 @@ public interface IAxisDrawingSettingsBase
{
double PlottingLength { get; }

double ActualTickInterval { get; }
double ActualTickInterval { get; }

int ActualTickCount { get; }
int ActualTickCount { get; }

bool CanUpdateAxisItems();
bool CanUpdateAxisItems();

bool CanUpdateAxisItemsCoordinate();
bool CanUpdateAxisItemsCoordinate();
}

public interface ILinearAxisDrawingSettings: IAxisDrawingSettingsBase
public interface INumericAxisDrawingSettings : IAxisDrawingSettingsBase
{
Range PlottingDataRange { get; }
}

public interface ICategoryAxisDrawingSettings : IAxisDrawingSettingsBase
{

IList<object> PlottingItemValues { get; }
}

public class AxisDrawingSettings: ILinearAxisDrawingSettings

public class NumericAxisDrawingSettings : INumericAxisDrawingSettings
{
public override string ToString()
{
Expand All @@ -42,25 +44,25 @@ public override string ToString()

#region generated values

public double ActualTickInterval { get; }
public double ActualTickInterval { get; }

public int ActualTickCount { get; }

#endregion

public AxisDrawingSettings(int tickCount, double tickInterval, Range range, double plottingLength)
public NumericAxisDrawingSettings(int tickCount, double tickInterval, Range range, double plottingLength)
{

if (tickCount<0 || tickCount>ushort.MaxValue)
if (tickCount < 0 || tickCount > ushort.MaxValue)
{
throw new NotSupportedException();
}



this.PlottingDataRange = range;


this.PlottingLength = plottingLength;

//calculated state:
Expand All @@ -71,28 +73,28 @@ public AxisDrawingSettings(int tickCount, double tickInterval, Range range, doub

public override bool Equals(object obj)
{
var other = obj as AxisDrawingSettings;
var other = obj as NumericAxisDrawingSettings;
if (other == null)
{
return false;
}

return this.PlottingLength.NearlyEqual(other.PlottingLength, 0.0001) &&
this.PlottingDataRange==other.PlottingDataRange &&
return this.PlottingLength.NearlyEqual(other.PlottingLength, 0.0001) &&
this.PlottingDataRange == other.PlottingDataRange &&
this.ActualTickCount == other.ActualTickCount &&
this.ActualTickInterval == other.ActualTickInterval;
}

public bool CanUpdateAxisItems()
{

return !this.PlottingLength.IsNaNOrZero() && !this.ActualTickInterval.IsNaNOrZero();
}

public bool CanUpdateAxisItemsCoordinate()
{
return !this.PlottingLength.IsNaNOrZero() && !this.PlottingDataRange.Span.IsNaNOrZero();
}

}
}
Loading

0 comments on commit e77861d

Please sign in to comment.