Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
beto-rodriguez committed Feb 12, 2017
1 parent a6e9400 commit a5566e5
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Core/AxisCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ internal virtual CoreMargin PrepareChart(AxisOrientation source, ChartCore chart
InitializeGarbageCollector();

var bl = Math.Ceiling(BotLimit/Magnitude)*Magnitude;
var u = View.BarUnit != 1d
? View.BarUnit
: View.Unit;
if (u != 1d)
{
bl = Math.Ceiling(BotLimit / u) * u;
}
bl = Math.Round(bl/u)*u;
FirstSeparator = bl;

for (var i = bl; i <= TopLimit - (EvaluatesUnitWidth ? 1 : 0); i += S)
Expand Down
8 changes: 6 additions & 2 deletions Core/ChartFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,17 @@ public static double GetUnitWidth(AxisOrientation source, ChartCore chart, AxisC
if (source == AxisOrientation.Y)
{
min = axis.BotLimit;
u = axis.View.BarUnit;
u = axis.View.BarUnit != 1d
? axis.View.BarUnit
: axis.View.Unit;
return ToDrawMargin(min, AxisOrientation.Y, chart, axis) -
ToDrawMargin(min + u, AxisOrientation.Y, chart, axis);
}

min = axis.BotLimit;
u = axis.View.BarUnit;
u = axis.View.BarUnit != 1d
? axis.View.BarUnit
: axis.View.Unit;
return ToDrawMargin(min + u, AxisOrientation.X, chart, axis) -
ToDrawMargin(min, AxisOrientation.X, chart, axis);
}
Expand Down
9 changes: 9 additions & 0 deletions Core/Definitions/Charts/IAxisView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.

using System;
using LiveCharts.Charts;
using LiveCharts.Dtos;

Expand Down Expand Up @@ -99,6 +100,14 @@ public interface IAxisView
/// <value>
/// The bar unit.
/// </value>
double Unit { get; set; }
/// <summary>
/// Gets or sets the bar unit.
/// </summary>
/// <value>
/// The bar unit.
/// </value>
[Obsolete]
double BarUnit { get; set; }
/// <summary>
/// Gets the previous maximum value.
Expand Down
8 changes: 8 additions & 0 deletions Core40/AxisCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ internal virtual CoreMargin PrepareChart(AxisOrientation source, ChartCore chart
InitializeGarbageCollector();

var bl = Math.Ceiling(BotLimit/Magnitude)*Magnitude;
var u = View.BarUnit != 1d
? View.BarUnit
: View.Unit;
if (u != 1d)
{
bl = Math.Ceiling(BotLimit / u) * u;
}
bl = Math.Round(bl/u)*u;
FirstSeparator = bl;

for (var i = bl; i <= TopLimit - (EvaluatesUnitWidth ? 1 : 0); i += S)
Expand Down
8 changes: 6 additions & 2 deletions Core40/ChartFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,17 @@ public static double GetUnitWidth(AxisOrientation source, ChartCore chart, AxisC
if (source == AxisOrientation.Y)
{
min = axis.BotLimit;
u = axis.View.BarUnit;
u = axis.View.BarUnit != 1d
? axis.View.BarUnit
: axis.View.Unit;
return ToDrawMargin(min, AxisOrientation.Y, chart, axis) -
ToDrawMargin(min + u, AxisOrientation.Y, chart, axis);
}

min = axis.BotLimit;
u = axis.View.BarUnit;
u = axis.View.BarUnit != 1d
? axis.View.BarUnit
: axis.View.Unit;
return ToDrawMargin(min + u, AxisOrientation.X, chart, axis) -
ToDrawMargin(min, AxisOrientation.X, chart, axis);
}
Expand Down
9 changes: 9 additions & 0 deletions Core40/Definitions/Charts/IAxisView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.

using System;
using LiveCharts.Charts;
using LiveCharts.Dtos;

Expand Down Expand Up @@ -99,6 +100,14 @@ public interface IAxisView
/// <value>
/// The bar unit.
/// </value>
double Unit { get; set; }
/// <summary>
/// Gets or sets the bar unit.
/// </summary>
/// <value>
/// The bar unit.
/// </value>
[Obsolete]
double BarUnit { get; set; }
/// <summary>
/// Gets the previous maximum value.
Expand Down
1 change: 0 additions & 1 deletion WpfView/AxesCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
//SOFTWARE.

using System.Collections.Generic;
using System.Xml;
using LiveCharts.Helpers;
using LiveCharts.Wpf.Charts.Base;

Expand Down
18 changes: 18 additions & 0 deletions WpfView/Axis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,30 @@ public double LabelsRotation
/// <summary>
/// Gets or sets the bar's series unit width (rows and columns), this property specifies the value in the chart that any bar should take as width.
/// </summary>
[Obsolete("Please use Unit property instead.")]
public double BarUnit
{
get { return (double) GetValue(BarUnitProperty); }
set { SetValue(BarUnitProperty, value); }
}

/// <summary>
/// The unit property
/// </summary>
public static readonly DependencyProperty UnitProperty = DependencyProperty.Register(
"Unit", typeof(double), typeof(Axis), new PropertyMetadata(1d));
/// <summary>
/// Gets or sets the axis unit, setting this property to your actual scale unit (seconds, minutes or any other scale) helps you to fix possible visual issues.
/// </summary>
/// <value>
/// The unit.
/// </value>
public double Unit
{
get { return (double) GetValue(UnitProperty); }
set { SetValue(UnitProperty, value); }
}

/// <summary>
/// The axis orientation property
/// </summary>
Expand Down

0 comments on commit a5566e5

Please sign in to comment.