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

123

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