Commit 176bb4df authored by 潘栩锋's avatar 潘栩锋 🚴

123

parent ed182e01
......@@ -24,13 +24,14 @@ using LiveCharts.Definitions.Charts;
using LiveCharts.Definitions.Points;
using LiveCharts.Definitions.Series;
using LiveCharts.Dtos;
using System;
namespace LiveCharts
{
/// <summary>
/// Defines a point in the chart
/// </summary>
public class ChartPoint
public class ChartPoint:IDisposable
{
#region Cartesian
//#modify by feng
......@@ -225,5 +226,10 @@ namespace LiveCharts
public IChartView ChartView { get { return SeriesView.Model.Chart.View; } }
internal double Gci { get; set; }
public void Dispose()
{
View = null;
}
}
}
\ No newline at end of file
......@@ -38,7 +38,8 @@ namespace LiveCharts.Helpers
/// <typeparam name="T">type to iterate with</typeparam>
/// <param name="source">collection to iterate</param>
/// <param name="predicate">action to execute</param>
internal static void ForEach<T>(this IEnumerable<T> source, Action<T> predicate)
//internal static void ForEach<T>(this IEnumerable<T> source, Action<T> predicate)
public static void ForEach<T>(this IEnumerable<T> source, Action<T> predicate)
{
foreach (var item in source) predicate(item);
}
......@@ -48,7 +49,8 @@ namespace LiveCharts.Helpers
/// </summary>
/// <param name="toSplit">collection to split</param>
/// <returns>collection of collections</returns>
internal static IEnumerable<IList<ChartPoint>> SplitEachNaN(this IList<ChartPoint> toSplit)
//internal static IEnumerable<IList<ChartPoint>> SplitEachNaN(this IList<ChartPoint> toSplit)
public static IEnumerable<IList<ChartPoint>> SplitEachNaN(this IList<ChartPoint> toSplit)
{
var l = new List<ChartPoint>(toSplit.Count);
var acum = -1;
......@@ -75,7 +77,8 @@ namespace LiveCharts.Helpers
/// </summary>
/// <param name="axis">current orientation</param>
/// <returns>inverted axis orientation</returns>
internal static AxisOrientation Invert(this AxisOrientation axis)
//internal static AxisOrientation Invert(this AxisOrientation axis)
public static AxisOrientation Invert(this AxisOrientation axis)
{
return axis == AxisOrientation.X
? AxisOrientation.Y
......
......@@ -82,7 +82,7 @@ namespace LiveCharts.SeriesAlgorithms
double weight = ChartFunctions2.GetUnitWidth( chartPoint.Weight, AxisOrientation.X, Chart, View.ScalesXAt);
chartPoint.View = View.GetPointView(chartPoint,
View.DataLabels ? View.GetLabelPointFormatter()(chartPoint) : null);
......
......@@ -20,18 +20,38 @@
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.
//using System;
//using System.Windows;
//using System.Windows.Controls;
//using System.Windows.Media;
//using System.Windows.Shapes;
//using LiveCharts.Definitions.Points;
//using LiveCharts.Definitions.Series;
//using LiveCharts.Dtos;
//using LiveCharts.SeriesAlgorithms;
//using LiveCharts.Wpf.Charts.Base;
//using LiveCharts.Wpf.Points;
//using LiveCharts.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using LiveCharts.Definitions.Points;
using LiveCharts.Definitions.Series;
using LiveCharts.Dtos;
using LiveCharts.Helpers;
using LiveCharts.SeriesAlgorithms;
using LiveCharts.Wpf.Charts.Base;
using LiveCharts.Wpf.Components;
using LiveCharts.Wpf.Points;
namespace LiveCharts.Wpf
{
/// <summary>
......@@ -181,6 +201,18 @@ namespace LiveCharts.Wpf
return pbv;
}
///// <summary>
///// Erases series
///// </summary>
//public override void Erase(bool removeFromView = true)
//{
// ActualValues.GetPoints(this).ForEach(p =>
// {
// if (p.View != null)
// p.View.RemoveFromView(Model.Chart);
// });
// if (removeFromView) Model.Chart.View.RemoveFromView(this);
//}
#endregion
#region Private Methods
......
......@@ -32,6 +32,7 @@
<TextBlock Text="{Binding IsRunning,Mode=OneWay}"/>
</StackPanel>
<Button Content="Update" Width="80" Padding="5" Click="Button_Click"/>
<Button Content="GC" Width="80" Padding="5" Click="ButtonGC_Click"/>
</StackPanel>
</Grid>
</Window>
\ No newline at end of file
......@@ -41,6 +41,11 @@ namespace WpfApp1
else
viewModel.Start();
}
private void ButtonGC_Click(object sender, RoutedEventArgs e)
{
GC.Collect();
}
}
public class ColumnRangeExampleViewModel : INotifyPropertyChanged
{
......@@ -97,11 +102,22 @@ namespace WpfApp1
v = double.NaN;
boltValues.Add(new BoltValue(bolt.Begin, bolt.End, v));
}
// if (SeriesCollection.Count() > 0)
// SeriesCollection.Clear();
BoltValues.Clear();
Values.Clear();
BoltValues.AddRange(boltValues);
Values.AddRange(datas2);
}
public void Init()
{
......@@ -133,35 +149,26 @@ namespace WpfApp1
}
boltmap[2].End = (boltmap[3].End + boltmap[3].Begin) / 2;
SeriesCollection = new SeriesCollection
{
new LineSeries
{
Title = "Line",
Values = Values,
StrokeThickness = 2,
Stroke = new SolidColorBrush(System.Windows.Media.Colors.Blue),
Fill = new SolidColorBrush(System.Windows.Media.Colors.Transparent),
PointGeometry = null,
},
new ColumnRangeSeries
{
Title = "ColumnRange",
Values = BoltValues,
StrokeThickness = 2,
Stroke = new SolidColorBrush(System.Windows.Media.Colors.DarkRed),
Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x80, 0xff,0,0)),
DataLabels = true,
YAxisCrossing = 150,
Configuration = Mappers.Weighted<BoltValue>()
.X(b=>(b.From + b.To)/2)
.Weight(b=> Math.Abs(b.From-b.To))
.Y(b=>b.Value)
}
};
SeriesCollection = new SeriesCollection();
SeriesCollection.Add(
new ColumnRangeSeries
{
Title = "ColumnRange",
Values = BoltValues,
StrokeThickness = 2,
Stroke = new SolidColorBrush(System.Windows.Media.Colors.DarkRed),
Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0x80, 0xff, 0, 0)),
DataLabels = true,
YAxisCrossing = 150,
Configuration = Mappers.Weighted<BoltValue>()
.X(b => (b.From + b.To) / 2)
.Weight(b => Math.Abs(b.From - b.To))
.Y(b => b.Value)
});
Formatter = value => value.ToString("N");
XMin = 100;
XMax = 900;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment