Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #458 from beto-rodriguez/develop
Browse files Browse the repository at this point in the history
0.9.3 release
  • Loading branch information
beto-rodriguez authored Feb 13, 2017
2 parents 34622a2 + c9fcc8d commit c998895
Show file tree
Hide file tree
Showing 41 changed files with 734 additions and 138 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
2 changes: 0 additions & 2 deletions Core/ChartUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ protected void Update(bool restartsAnimations = false)

foreach (var series in Chart.View.ActualSeries)
{
if (Chart.View.ContainsElement(series)) continue;

InitializeSeriesView(series);
series.ActualValues.Initialize(series);
series.InitializeColors();
Expand Down
15 changes: 7 additions & 8 deletions Core/ChartValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ public void Initialize(ISeriesView seriesView)

var cp = new ChartPoint();

var source = this.ToArray();

var ax = seriesView.Model.Chart.AxisX[seriesView.ScalesXAt];
var ay = seriesView.Model.Chart.AxisY[seriesView.ScalesYAt];
double fx = double.IsNaN(ax.MinValue) ? double.NegativeInfinity : ax.MinValue,
Expand All @@ -98,10 +96,11 @@ public void Initialize(ISeriesView seriesView)

var isHorizontal = seriesView.Model.SeriesOrientation == SeriesOrientation.Horizontal;

for (var index = 0; index < source.Length; index++)
var index = 0;
foreach(var item in this)
{
var item = source[index];
config.Evaluate(index, item, cp);
index++;

if (isHorizontal)
{
Expand Down Expand Up @@ -154,6 +153,7 @@ public void Initialize(ISeriesView seriesView)
tracker.WLimit = new CoreLimit(double.IsInfinity(wMin)
? 0
: wMin, double.IsInfinity(wMax) ? 1 : wMax);

}

/// <summary>
Expand All @@ -180,11 +180,9 @@ public IEnumerable<ChartPoint> GetPoints(ISeriesView seriesView)
var tracker = GetTracker(seriesView);
var gci = tracker.Gci;

var source = this.ToList(); //copy it, to prevent async issues

for (var index = 0; index < source.Count; index++)
var index = 0;
foreach (var value in this)
{
var value = source[index];
if (isObservable)
{
var observable = (IObservableChartPoint)value;
Expand All @@ -203,6 +201,7 @@ public IEnumerable<ChartPoint> GetPoints(ISeriesView seriesView)
cp.SeriesView = seriesView;

config.Evaluate(index, value, cp);
index++;

yield return cp;
}
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
7 changes: 1 addition & 6 deletions Core/Definitions/Charts/IChartView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,7 @@ public interface IChartView
/// </summary>
/// <param name="element">The element.</param>
void EnsureElementBelongsToCurrentDrawMargin(object element);
/// <summary>
/// Determines whether the specified element contains element.
/// </summary>
/// <param name="element">The element.</param>
bool ContainsElement(object element);


/// <summary>
/// Hides the tooltip.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions Core/Definitions/Series/ISeriesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ public interface ISeriesView
/// The title.
/// </value>
string Title { get; }
/// <summary>
/// Gets a value indicating whether this instance is first draw.
/// </summary>
/// <value>
/// <c>true</c> if this instance is first draw; otherwise, <c>false</c>.
/// </value>
bool IsFirstDraw { get; }

/// <summary>
/// Gets the point view.
Expand Down
94 changes: 76 additions & 18 deletions Core/Helpers/NoisyCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public interface INoisyCollection : IList, INotifyPropertyChanged, INotifyCollec
public class NoisyCollection<T> : INoisyCollection, IList<T>
{
#region Private Fields
private readonly object _sync = new object();
private readonly List<T> _source;
private const string CountString = "Count";
private const string IndexerString = "Item[]";
Expand Down Expand Up @@ -153,11 +154,20 @@ event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
/// <returns></returns>
public T this[int index]
{
get { return _source[index]; }
get
{
lock (_sync)
{
return _source[index];
}
}
set
{
var original = this[index];
_source[index] = value;
lock (_sync)
{
_source[index] = value;
}
ReplaceItem(original, value, index);
}
}
Expand All @@ -169,11 +179,20 @@ public T this[int index]
/// <returns></returns>
object IList.this[int index]
{
get { return _source[index]; }
get
{
lock (_sync)
{
return _source[index];
}
}
set
{
var original = this[index];
_source[index] = (T)value;
lock (_sync)
{
_source[index] = (T)value;
}
ReplaceItem(original, value, index);
}
}
Expand All @@ -184,7 +203,10 @@ object IList.this[int index]
/// <returns>collection enumeration</returns>
public IEnumerator<T> GetEnumerator()
{
return _source.GetEnumerator();
lock (_sync)
{
return new List<T>(_source).GetEnumerator();
}
}

/// <summary>
Expand Down Expand Up @@ -257,7 +279,10 @@ int IList.Add(object value)
{
var v = (T)value;
Add(v);
return _source.IndexOf(v);
lock (_sync)
{
return _source.IndexOf(v);
}
}

/// <summary>
Expand All @@ -266,7 +291,10 @@ int IList.Add(object value)
/// <returns>number of items in the collection</returns>
public void Add(T item)
{
_source.Add(item);
lock (_sync)
{
_source.Add(item);
}
OnNoisyCollectionChanged(null, new[] { item });
OnPropertyChanged(CountString);
OnPropertyChanged(IndexerString);
Expand All @@ -290,7 +318,10 @@ public void AddRange(IEnumerable<object> items)
public void AddRange(IEnumerable<T> items)
{
var newItems = items as T[] ?? items.ToArray();
_source.AddRange(newItems);
lock (_sync)
{
_source.AddRange(newItems);
}
OnNoisyCollectionChanged(null, newItems);
OnPropertyChanged(CountString);
OnPropertyChanged(IndexerString);
Expand All @@ -307,7 +338,10 @@ public void AddRange(IEnumerable<T> items)
/// <param name="item">item to insert</param>
public void Insert(int index, T item)
{
_source.Insert(index, item);
lock (_sync)
{
_source.Insert(index, item);
}
OnNoisyCollectionChanged(null, new[] { item });
OnPropertyChanged(CountString);
OnPropertyChanged(IndexerString);
Expand Down Expand Up @@ -343,7 +377,10 @@ public void InsertRange(int index, IEnumerable<object> collection)
public void InsertRange(int index, IEnumerable<T> collection)
{
var newItems = collection as T[] ?? collection.ToArray();
_source.InsertRange(index, newItems);
lock (_sync)
{
_source.InsertRange(index, newItems);
}
OnNoisyCollectionChanged(null, newItems);
OnPropertyChanged(CountString);
OnPropertyChanged(IndexerString);
Expand All @@ -369,7 +406,11 @@ public void Remove(object value)
/// <returns>number of items in the collection</returns>
public bool Remove(T item)
{
var index = _source.IndexOf(item);
int index;
lock (_sync)
{
index = _source.IndexOf(item);
}
if (index < 0) return false;
RemoveAt(index);
return true;
Expand Down Expand Up @@ -399,8 +440,12 @@ void IList<T>.RemoveAt(int index)
/// <param name="index">index to remove at</param>
public void RemoveAt(int index)
{
var item = _source[index];
_source.RemoveAt(index);
T item;
lock (_sync)
{
item = _source[index];
_source.RemoveAt(index);
}
OnNoisyCollectionChanged(new[] { item }, null);
OnPropertyChanged(CountString);
OnPropertyChanged(IndexerString);
Expand Down Expand Up @@ -429,8 +474,12 @@ void ICollection<T>.Clear()
/// </summary>
public void Clear()
{
var backup = _source.ToArray();
_source.Clear();
T[] backup;
lock (_sync)
{
backup = _source.ToArray();
_source.Clear();
}
OnNoisyCollectionChanged(backup, null);
OnNoisyCollectionReset();
OnPropertyChanged(CountString);
Expand All @@ -455,7 +504,10 @@ public bool Contains(object value)
/// <returns>evaluation</returns>
public bool Contains(T item)
{
return _source.Contains(item);
lock (_sync)
{
return _source.Contains(item);
}
}

/// <summary>
Expand All @@ -475,7 +527,10 @@ public void CopyTo(Array array, int index)
/// <param name="index">array index</param>
public void CopyTo(T[] array, int index)
{
_source.CopyTo(array, index);
lock (_sync)
{
_source.CopyTo(array, index);
}
}

/// <summary>
Expand All @@ -495,7 +550,10 @@ public int IndexOf(object value)
/// <returns></returns>
public int IndexOf(T item)
{
return _source.IndexOf(item);
lock (_sync)
{
return _source.IndexOf(item);
}
}

#endregion
Expand Down
4 changes: 2 additions & 2 deletions Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.2")]
[assembly: AssemblyFileVersion("0.9.2")]
[assembly: AssemblyVersion("0.9.3")]
[assembly: AssemblyFileVersion("0.9.3")]

[assembly: InternalsVisibleTo("LiveCharts.Wpf")]
[assembly: InternalsVisibleTo("LiveCharts.Uwp")]
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
Loading

0 comments on commit c998895

Please sign in to comment.