mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-26 19:23:24 +08:00
项目结构调整
This commit is contained in:
539
Others/Live-Charts-master/WpfView/AngularGauge.cs
Normal file
539
Others/Live-Charts-master/WpfView/AngularGauge.cs
Normal file
@@ -0,0 +1,539 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using System.Linq;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Effects;
|
||||
using LiveCharts.Helpers;
|
||||
using LiveCharts.Wpf.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The gauge chart is useful to display progress or completion.
|
||||
/// </summary>
|
||||
public class AngularGauge : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AngularGauge"/> class.
|
||||
/// </summary>
|
||||
public AngularGauge()
|
||||
{
|
||||
Canvas = new Canvas();
|
||||
Content = Canvas;
|
||||
|
||||
StickRotateTransform = new RotateTransform(180);
|
||||
Stick = new Path
|
||||
{
|
||||
Data = Geometry.Parse("m0,90 a5,5 0 0 0 20,0 l-8,-88 a2,2 0 0 0 -4 0 z"),
|
||||
Fill = Brushes.CornflowerBlue,
|
||||
Stretch = Stretch.Fill,
|
||||
RenderTransformOrigin = new Point(0.5, 0.9),
|
||||
RenderTransform = StickRotateTransform
|
||||
};
|
||||
Canvas.Children.Add(Stick);
|
||||
Panel.SetZIndex(Stick, 1);
|
||||
|
||||
Canvas.SetBinding(WidthProperty,
|
||||
new Binding { Path = new PropertyPath(ActualWidthProperty), Source = this });
|
||||
Canvas.SetBinding(HeightProperty,
|
||||
new Binding { Path = new PropertyPath(ActualHeightProperty), Source = this });
|
||||
|
||||
SetCurrentValue(SectionsProperty, new List<AngularSection>());
|
||||
SetCurrentValue(NeedleFillProperty, new SolidColorBrush(Color.FromRgb(69, 90, 100)));
|
||||
|
||||
Stick.SetBinding(Shape.FillProperty,
|
||||
new Binding {Path = new PropertyPath(NeedleFillProperty), Source = this});
|
||||
|
||||
SetCurrentValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(500));
|
||||
SetCurrentValue(TicksForegroundProperty, new SolidColorBrush(Color.FromRgb(210, 210, 210)));
|
||||
Func<double, string> defaultFormatter = x => x.ToString(CultureInfo.InvariantCulture);
|
||||
SetCurrentValue(LabelFormatterProperty, defaultFormatter);
|
||||
SetCurrentValue(LabelsEffectProperty,
|
||||
new DropShadowEffect {ShadowDepth = 2, RenderingBias = RenderingBias.Performance});
|
||||
|
||||
SizeChanged += (sender, args) =>
|
||||
{
|
||||
IsControlLaoded = true;
|
||||
Draw();
|
||||
};
|
||||
|
||||
Slices = new Dictionary<AngularSection, PieSlice>();
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
private Canvas Canvas { get; set; }
|
||||
private Path Stick { get; set; }
|
||||
private RotateTransform StickRotateTransform { get; set; }
|
||||
private bool IsControlLaoded { get; set; }
|
||||
private Dictionary<AngularSection, PieSlice> Slices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The wedge property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty WedgeProperty = DependencyProperty.Register(
|
||||
"Wedge", typeof (double), typeof (AngularGauge),
|
||||
new PropertyMetadata(300d, Redraw));
|
||||
/// <summary>
|
||||
/// Gets or sets the opening angle in the gauge
|
||||
/// </summary>
|
||||
public double Wedge
|
||||
{
|
||||
get { return (double) GetValue(WedgeProperty); }
|
||||
set { SetValue(WedgeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ticks step property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TicksStepProperty = DependencyProperty.Register(
|
||||
"TicksStep", typeof (double), typeof (AngularGauge),
|
||||
new PropertyMetadata(double.NaN, Redraw));
|
||||
/// <summary>
|
||||
/// Gets or sets the separation between every tick
|
||||
/// </summary>
|
||||
public double TicksStep
|
||||
{
|
||||
get { return (double) GetValue(TicksStepProperty); }
|
||||
set { SetValue(TicksStepProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The labels step property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelsStepProperty = DependencyProperty.Register(
|
||||
"LabelsStep", typeof (double), typeof (AngularGauge),
|
||||
new PropertyMetadata(double.NaN, Redraw));
|
||||
/// <summary>
|
||||
/// Gets or sets the separation between every label
|
||||
/// </summary>
|
||||
public double LabelsStep
|
||||
{
|
||||
get { return (double) GetValue(LabelsStepProperty); }
|
||||
set { SetValue(LabelsStepProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FromValueProperty = DependencyProperty.Register(
|
||||
"FromValue", typeof (double), typeof (AngularGauge),
|
||||
new PropertyMetadata(0d, Redraw));
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum value of the gauge
|
||||
/// </summary>
|
||||
public double FromValue
|
||||
{
|
||||
get { return (double) GetValue(FromValueProperty); }
|
||||
set { SetValue(FromValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ToValueProperty = DependencyProperty.Register(
|
||||
"ToValue", typeof (double), typeof (AngularGauge),
|
||||
new PropertyMetadata(100d, Redraw));
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum value of the gauge
|
||||
/// </summary>
|
||||
public double ToValue
|
||||
{
|
||||
get { return (double) GetValue(ToValueProperty); }
|
||||
set { SetValue(ToValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sections property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SectionsProperty = DependencyProperty.Register(
|
||||
"Sections", typeof (List<AngularSection>), typeof (AngularGauge),
|
||||
new PropertyMetadata(default(SectionsCollection), Redraw));
|
||||
/// <summary>
|
||||
/// Gets or sets a collection of sections
|
||||
/// </summary>
|
||||
public List<AngularSection> Sections
|
||||
{
|
||||
get { return (List<AngularSection>) GetValue(SectionsProperty); }
|
||||
set { SetValue(SectionsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
|
||||
"Value", typeof (double), typeof (AngularGauge),
|
||||
new PropertyMetadata(default(double), ValueChangedCallback));
|
||||
/// <summary>
|
||||
/// Gets or sets the current gauge value
|
||||
/// </summary>
|
||||
public double Value
|
||||
{
|
||||
get { return (double) GetValue(ValueProperty); }
|
||||
set { SetValue(ValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The label formatter property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelFormatterProperty = DependencyProperty.Register(
|
||||
"LabelFormatter", typeof (Func<double, string>), typeof (AngularGauge), new PropertyMetadata(default(Func<double, string>)));
|
||||
/// <summary>
|
||||
/// Gets or sets the label formatter
|
||||
/// </summary>
|
||||
public Func<double, string> LabelFormatter
|
||||
{
|
||||
get { return (Func<double, string>) GetValue(LabelFormatterProperty); }
|
||||
set { SetValue(LabelFormatterProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The disablea animations property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DisableaAnimationsProperty = DependencyProperty.Register(
|
||||
"DisableaAnimations", typeof (bool), typeof (AngularGauge), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets whether the chart is animated
|
||||
/// </summary>
|
||||
public bool DisableaAnimations
|
||||
{
|
||||
get { return (bool) GetValue(DisableaAnimationsProperty); }
|
||||
set { SetValue(DisableaAnimationsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The animations speed property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty AnimationsSpeedProperty = DependencyProperty.Register(
|
||||
"AnimationsSpeed", typeof (TimeSpan), typeof (AngularGauge), new PropertyMetadata(default(TimeSpan)));
|
||||
/// <summary>
|
||||
/// Gets or sets the animations speed
|
||||
/// </summary>
|
||||
public TimeSpan AnimationsSpeed
|
||||
{
|
||||
get { return (TimeSpan) GetValue(AnimationsSpeedProperty); }
|
||||
set { SetValue(AnimationsSpeedProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ticks foreground property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TicksForegroundProperty = DependencyProperty.Register(
|
||||
"TicksForeground", typeof (Brush), typeof (AngularGauge), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the ticks foreground
|
||||
/// </summary>
|
||||
public Brush TicksForeground
|
||||
{
|
||||
get { return (Brush) GetValue(TicksForegroundProperty); }
|
||||
set { SetValue(TicksForegroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sections inner radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SectionsInnerRadiusProperty = DependencyProperty.Register(
|
||||
"SectionsInnerRadius", typeof (double), typeof (AngularGauge),
|
||||
new PropertyMetadata(0.94d, Redraw));
|
||||
/// <summary>
|
||||
/// Gets or sets the inner radius of all the sections in the chart, the unit of this property is percentage, goes from 0 to 1
|
||||
/// </summary>
|
||||
public double SectionsInnerRadius
|
||||
{
|
||||
get { return (double) GetValue(SectionsInnerRadiusProperty); }
|
||||
set { SetValue(SectionsInnerRadiusProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The needle fill property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty NeedleFillProperty = DependencyProperty.Register(
|
||||
"NeedleFill", typeof (Brush), typeof (AngularGauge), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets o sets the needle fill
|
||||
/// </summary>
|
||||
public Brush NeedleFill
|
||||
{
|
||||
get { return (Brush) GetValue(NeedleFillProperty); }
|
||||
set { SetValue(NeedleFillProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The labels effect property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelsEffectProperty = DependencyProperty.Register(
|
||||
"LabelsEffect", typeof (Effect), typeof (AngularGauge), new PropertyMetadata(default(Effect)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the labels effect.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The labels effect.
|
||||
/// </value>
|
||||
public Effect LabelsEffect
|
||||
{
|
||||
get { return (Effect) GetValue(LabelsEffectProperty); }
|
||||
set { SetValue(LabelsEffectProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ticks stroke thickness property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TicksStrokeThicknessProperty = DependencyProperty.Register(
|
||||
"TicksStrokeThickness", typeof (double), typeof (AngularGauge), new PropertyMetadata(2d));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ticks stroke thickness.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The ticks stroke thickness.
|
||||
/// </value>
|
||||
public double TicksStrokeThickness
|
||||
{
|
||||
get { return (double) GetValue(TicksStrokeThicknessProperty); }
|
||||
set { SetValue(TicksStrokeThicknessProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static void ValueChangedCallback(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ag = (AngularGauge)o;
|
||||
ag.MoveStick();
|
||||
}
|
||||
|
||||
private static void Redraw(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ag = (AngularGauge) o;
|
||||
ag.Draw();
|
||||
}
|
||||
|
||||
private void MoveStick()
|
||||
{
|
||||
Wedge = Wedge > 360 ? 360 : (Wedge < 0 ? 0 : Wedge);
|
||||
|
||||
var fromAlpha = (360 - Wedge) * .5;
|
||||
var toAlpha = 360 - fromAlpha;
|
||||
|
||||
var alpha = LinearInterpolation(fromAlpha, toAlpha, FromValue, ToValue, Value) + 180;
|
||||
|
||||
if (DisableaAnimations)
|
||||
{
|
||||
StickRotateTransform.Angle = alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
StickRotateTransform.BeginAnimation(RotateTransform.AngleProperty,
|
||||
new DoubleAnimation(alpha, AnimationsSpeed));
|
||||
}
|
||||
}
|
||||
|
||||
internal void Draw()
|
||||
{
|
||||
if (!IsControlLaoded) return;
|
||||
|
||||
//No cache for you gauge :( kill and redraw please
|
||||
foreach (var child in Canvas.Children.Cast<UIElement>()
|
||||
.Where(x => !Equals(x, Stick) && !(x is AngularSection) && !(x is PieSlice)).ToArray())
|
||||
Canvas.Children.Remove(child);
|
||||
|
||||
Wedge = Wedge > 360 ? 360 : (Wedge < 0 ? 0 : Wedge);
|
||||
|
||||
var fromAlpha = (360-Wedge)*.5;
|
||||
var toAlpha = 360 - fromAlpha;
|
||||
|
||||
var d = ActualWidth < ActualHeight ? ActualWidth : ActualHeight;
|
||||
|
||||
Stick.Height = d*.5*.8;
|
||||
Stick.Width = Stick.Height*.2;
|
||||
|
||||
Canvas.SetLeft(Stick, ActualWidth*.5 - Stick.Width*.5);
|
||||
Canvas.SetTop(Stick, ActualHeight*.5 - Stick.Height*.9);
|
||||
|
||||
var ticksHi = d*.5;
|
||||
var ticksHj = d*.47;
|
||||
var labelsHj = d*.44;
|
||||
|
||||
foreach (var section in Sections)
|
||||
{
|
||||
PieSlice slice;
|
||||
|
||||
section.Owner = this;
|
||||
|
||||
if (!Slices.TryGetValue(section, out slice))
|
||||
{
|
||||
slice = new PieSlice();
|
||||
Slices[section] = slice;
|
||||
}
|
||||
|
||||
var p = (Canvas)section.Parent;
|
||||
if (p != null) p.Children.Remove(section);
|
||||
Canvas.Children.Add(section);
|
||||
var ps = (Canvas)slice.Parent;
|
||||
if (ps != null) ps.Children.Remove(slice);
|
||||
Canvas.Children.Add(slice);
|
||||
}
|
||||
|
||||
UpdateSections();
|
||||
|
||||
var ts = double.IsNaN(TicksStep) ? DecideInterval((ToValue - FromValue)/5) : TicksStep;
|
||||
if (ts / (FromValue - ToValue) > 300)
|
||||
throw new LiveChartsException("TicksStep property is too small compared with the range in " +
|
||||
"the gauge, to avoid performance issues, please increase it.");
|
||||
|
||||
for (var i = FromValue; i <= ToValue; i += ts)
|
||||
{
|
||||
var alpha = LinearInterpolation(fromAlpha, toAlpha, FromValue, ToValue, i) + 90;
|
||||
|
||||
var tick = new Line
|
||||
{
|
||||
X1 = ActualWidth*.5 + ticksHi*Math.Cos(alpha*Math.PI/180),
|
||||
X2 = ActualWidth*.5 + ticksHj*Math.Cos(alpha*Math.PI/180),
|
||||
Y1 = ActualHeight*.5 + ticksHi*Math.Sin(alpha*Math.PI/180),
|
||||
Y2 = ActualHeight*.5 + ticksHj*Math.Sin(alpha*Math.PI/180)
|
||||
};
|
||||
Canvas.Children.Add(tick);
|
||||
tick.SetBinding(Shape.StrokeProperty,
|
||||
new Binding {Path = new PropertyPath(TicksForegroundProperty), Source = this});
|
||||
tick.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding { Path = new PropertyPath(TicksStrokeThicknessProperty), Source = this });
|
||||
}
|
||||
|
||||
var ls = double.IsNaN(LabelsStep) ? DecideInterval((ToValue - FromValue) / 5) : LabelsStep;
|
||||
if (ls / (FromValue - ToValue) > 300)
|
||||
throw new LiveChartsException("LabelsStep property is too small compared with the range in " +
|
||||
"the gauge, to avoid performance issues, please increase it.");
|
||||
|
||||
for (var i = FromValue; i <= ToValue; i += ls)
|
||||
{
|
||||
var alpha = LinearInterpolation(fromAlpha, toAlpha, FromValue, ToValue, i) + 90;
|
||||
|
||||
var tick = new Line
|
||||
{
|
||||
X1 = ActualWidth*.5 + ticksHi*Math.Cos(alpha*Math.PI/180),
|
||||
X2 = ActualWidth*.5 + labelsHj*Math.Cos(alpha*Math.PI/180),
|
||||
Y1 = ActualHeight*.5 + ticksHi*Math.Sin(alpha*Math.PI/180),
|
||||
Y2 = ActualHeight*.5 + labelsHj*Math.Sin(alpha*Math.PI/180)
|
||||
};
|
||||
|
||||
Canvas.Children.Add(tick);
|
||||
var label = new TextBlock
|
||||
{
|
||||
Text = LabelFormatter(i)
|
||||
};
|
||||
|
||||
label.SetBinding(EffectProperty,
|
||||
new Binding {Path = new PropertyPath(LabelsEffectProperty), Source = this});
|
||||
|
||||
Canvas.Children.Add(label);
|
||||
label.UpdateLayout();
|
||||
Canvas.SetLeft(label, alpha < 270
|
||||
? tick.X2
|
||||
: (Math.Abs(alpha - 270) < 4
|
||||
? tick.X2 - label.ActualWidth*.5
|
||||
: tick.X2 - label.ActualWidth));
|
||||
Canvas.SetTop(label, tick.Y2);
|
||||
tick.SetBinding(Shape.StrokeProperty,
|
||||
new Binding { Path = new PropertyPath(TicksForegroundProperty), Source = this });
|
||||
tick.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding { Path = new PropertyPath(TicksStrokeThicknessProperty), Source = this });
|
||||
}
|
||||
MoveStick();
|
||||
}
|
||||
|
||||
internal void UpdateSections()
|
||||
{
|
||||
if (!IsControlLaoded) return;
|
||||
|
||||
var fromAlpha = (360 - Wedge) * .5;
|
||||
var toAlpha = 360 - fromAlpha;
|
||||
var d = ActualWidth < ActualHeight ? ActualWidth : ActualHeight;
|
||||
|
||||
if (Sections.Any())
|
||||
{
|
||||
SectionsInnerRadius = SectionsInnerRadius > 1
|
||||
? 1
|
||||
: (SectionsInnerRadius < 0
|
||||
? 0
|
||||
: SectionsInnerRadius);
|
||||
|
||||
foreach (var section in Sections)
|
||||
{
|
||||
var slice = Slices[section];
|
||||
|
||||
Canvas.SetTop(slice, ActualHeight * .5);
|
||||
Canvas.SetLeft(slice, ActualWidth * .5);
|
||||
|
||||
var start = LinearInterpolation(fromAlpha, toAlpha,
|
||||
FromValue, ToValue, section.FromValue) + 180;
|
||||
var end = LinearInterpolation(fromAlpha, toAlpha,
|
||||
FromValue, ToValue, section.ToValue) + 180;
|
||||
|
||||
slice.RotationAngle = start;
|
||||
slice.WedgeAngle = end - start;
|
||||
slice.Radius = d*.5;
|
||||
slice.InnerRadius = d*.5*SectionsInnerRadius;
|
||||
slice.Fill = section.Fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static double LinearInterpolation(double fromA, double toA, double fromB, double toB, double value)
|
||||
{
|
||||
var p1 = new Point(fromB, fromA);
|
||||
var p2 = new Point(toB, toA);
|
||||
|
||||
var deltaX = p2.X - p1.X;
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
||||
var m = (p2.Y - p1.Y)/(deltaX == 0 ? double.MinValue : deltaX);
|
||||
|
||||
return m*(value - p1.X) + p1.Y;
|
||||
}
|
||||
|
||||
private static double DecideInterval(double minimum)
|
||||
{
|
||||
var magnitude = Math.Pow(10, Math.Floor(Math.Log(minimum) / Math.Log(10)));
|
||||
|
||||
var residual = minimum / magnitude;
|
||||
double tick;
|
||||
if (residual > 5)
|
||||
tick = 10 * magnitude;
|
||||
else if (residual > 2)
|
||||
tick = 5 * magnitude;
|
||||
else if (residual > 1)
|
||||
tick = 2 * magnitude;
|
||||
else
|
||||
tick = magnitude;
|
||||
|
||||
return tick;
|
||||
}
|
||||
}
|
||||
}
|
||||
100
Others/Live-Charts-master/WpfView/AngularSection.cs
Normal file
100
Others/Live-Charts-master/WpfView/AngularSection.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.FrameworkElement" />
|
||||
public class AngularSection : FrameworkElement
|
||||
{
|
||||
internal AngularGauge Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// From value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FromValueProperty = DependencyProperty.Register(
|
||||
"FromValue", typeof(double), typeof(AngularSection), new PropertyMetadata(default(double), Redraw));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets from value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// From value.
|
||||
/// </value>
|
||||
public double FromValue
|
||||
{
|
||||
get { return (double) GetValue(FromValueProperty); }
|
||||
set { SetValue(FromValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ToValueProperty = DependencyProperty.Register(
|
||||
"ToValue", typeof(double), typeof(AngularSection), new PropertyMetadata(default(double), Redraw));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets to value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// To value.
|
||||
/// </value>
|
||||
public double ToValue
|
||||
{
|
||||
get { return (double) GetValue(ToValueProperty); }
|
||||
set { SetValue(ToValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fill property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FillProperty = DependencyProperty.Register(
|
||||
"Fill", typeof(Brush), typeof(AngularSection), new PropertyMetadata(default(Brush)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fill.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The fill.
|
||||
/// </value>
|
||||
public Brush Fill
|
||||
{
|
||||
get { return (Brush) GetValue(FillProperty); }
|
||||
set { SetValue(FillProperty, value); }
|
||||
}
|
||||
|
||||
private static void Redraw(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
var angularSection = (AngularSection) dependencyObject;
|
||||
|
||||
if (angularSection.Owner == null) return;
|
||||
|
||||
angularSection.Owner.UpdateSections();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
68
Others/Live-Charts-master/WpfView/AxesCollection.cs
Normal file
68
Others/Live-Charts-master/WpfView/AxesCollection.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using LiveCharts.Helpers;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores a collection of axis.
|
||||
/// </summary>
|
||||
public class AxesCollection : NoisyCollection<Axis>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of AxisCollection class
|
||||
/// </summary>
|
||||
public AxesCollection()
|
||||
{
|
||||
NoisyCollectionChanged += OnNoisyCollectionChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the chart that owns the series.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The chart.
|
||||
/// </value>
|
||||
public Chart Chart { get; internal set; }
|
||||
|
||||
private void OnNoisyCollectionChanged(IEnumerable<Axis> oldItems, IEnumerable<Axis> newItems)
|
||||
{
|
||||
if(Chart != null && Chart.Model != null)
|
||||
Chart.Model.Updater.Run();
|
||||
|
||||
if (oldItems == null) return;
|
||||
|
||||
foreach (var oldAxis in oldItems)
|
||||
{
|
||||
oldAxis.Clean();
|
||||
if (oldAxis.Model == null) continue;
|
||||
var chart = oldAxis.Model.Chart.View;
|
||||
if (chart == null) continue;
|
||||
chart.RemoveFromView(oldAxis);
|
||||
chart.RemoveFromView(oldAxis.Separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
778
Others/Live-Charts-master/WpfView/Axis.cs
Normal file
778
Others/Live-Charts-master/WpfView/Axis.cs
Normal file
@@ -0,0 +1,778 @@
|
||||
//copyright(c) 2016 Alberto Rodriguez
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Events;
|
||||
using LiveCharts.Wpf.Components;
|
||||
using LiveCharts.Wpf.Converters;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// An Axis of a chart
|
||||
/// </summary>
|
||||
public class Axis : FrameworkElement, IAxisView
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Axis class
|
||||
/// </summary>
|
||||
public Axis()
|
||||
{
|
||||
TitleBlock = BindATextBlock();
|
||||
SetCurrentValue(SeparatorProperty, new Separator());
|
||||
SetCurrentValue(ShowLabelsProperty, true);
|
||||
SetCurrentValue(SectionsProperty, new SectionsCollection());
|
||||
SetCurrentValue(ForegroundProperty, new SolidColorBrush(Color.FromRgb(170, 170, 170)));
|
||||
|
||||
TitleBlock.SetBinding(TextBlock.TextProperty,
|
||||
new Binding {Path = new PropertyPath(TitleProperty), Source = this});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// Occurs when an axis range changes by an user action (zooming or panning)
|
||||
/// </summary>
|
||||
public event RangeChangedHandler RangeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// The range changed command property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RangeChangedCommandProperty = DependencyProperty.Register(
|
||||
"RangeChangedCommand", typeof(ICommand), typeof(Axis), new PropertyMetadata(default(ICommand)));
|
||||
/// <summary>
|
||||
/// Gets or sets the command to execute when an axis range changes by an user action (zooming or panning)
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The range changed command.
|
||||
/// </value>
|
||||
public ICommand RangeChangedCommand
|
||||
{
|
||||
get { return (ICommand) GetValue(RangeChangedCommandProperty); }
|
||||
set { SetValue(RangeChangedCommandProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before an axis range changes by an user action (zooming or panning)
|
||||
/// </summary>
|
||||
public event PreviewRangeChangedHandler PreviewRangeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// The preview range changed command property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PreviewRangeChangedCommandProperty = DependencyProperty.Register(
|
||||
"PreviewRangeChangedCommand", typeof(ICommand), typeof(Axis), new PropertyMetadata(default(ICommand)));
|
||||
/// <summary>
|
||||
/// Gets or sets the command to execute before an axis range changes by an user action (zooming or panning)
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The preview range changed command.
|
||||
/// </value>
|
||||
public ICommand PreviewRangeChangedCommand
|
||||
{
|
||||
get { return (ICommand) GetValue(PreviewRangeChangedCommandProperty); }
|
||||
set { SetValue(PreviewRangeChangedCommandProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
private TextBlock TitleBlock { get; set; }
|
||||
private FormattedText FormattedTitle { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the Model of the axis, the model is used a DTO to communicate with the core of the library.
|
||||
/// </summary>
|
||||
public AxisCore Model { get; set; }
|
||||
/// <summary>
|
||||
/// Gets previous Min Value
|
||||
/// </summary>
|
||||
public double PreviousMinValue { get; internal set; }
|
||||
/// <summary>
|
||||
/// Gets previous Max Value
|
||||
/// </summary>
|
||||
public double PreviousMaxValue { get; internal set; }
|
||||
#endregion
|
||||
|
||||
#region Dependency Properties
|
||||
|
||||
/// <summary>
|
||||
/// The labels property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelsProperty = DependencyProperty.Register(
|
||||
"Labels", typeof (IList<string>), typeof (Axis),
|
||||
new PropertyMetadata(default(IList<string>), UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets axis labels, labels property stores the array to map for each index and value, for example if axis value is 0 then label will be labels[0], when value 1 then labels[1], value 2 then labels[2], ..., value n labels[n], use this property instead of a formatter when there is no conversion between value and label for example names, if you are plotting sales vs salesman name.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(StringCollectionConverter))]
|
||||
public IList<string> Labels
|
||||
{
|
||||
get { return ThreadAccess.Resolve<IList<string>>(this, LabelsProperty); }
|
||||
set { SetValue(LabelsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sections property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SectionsProperty = DependencyProperty.Register(
|
||||
"Sections", typeof (SectionsCollection), typeof (Axis), new PropertyMetadata(default(SectionsCollection)));
|
||||
/// <summary>
|
||||
/// Gets or sets the axis sectionsCollection, a section is useful to highlight ranges or values in a chart.
|
||||
/// </summary>
|
||||
public SectionsCollection Sections
|
||||
{
|
||||
get { return (SectionsCollection) GetValue(SectionsProperty); }
|
||||
set { SetValue(SectionsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The label formatter property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelFormatterProperty = DependencyProperty.Register(
|
||||
"LabelFormatter", typeof (Func<double, string>), typeof (Axis),
|
||||
new PropertyMetadata(default(Func<double, string>), UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets the function to convert a value to label, for example when you need to display your chart as currency ($1.00) or as degrees (10°), if Labels property is not null then formatter is ignored, and label will be pulled from Labels prop.
|
||||
/// </summary>
|
||||
public Func<double, string> LabelFormatter
|
||||
{
|
||||
get { return (Func<double, string>) GetValue(LabelFormatterProperty); }
|
||||
set { SetValue(LabelFormatterProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The separator property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SeparatorProperty = DependencyProperty.Register(
|
||||
"Separator", typeof (Separator), typeof (Axis),
|
||||
new PropertyMetadata(default(Separator), UpdateChart()));
|
||||
/// <summary>
|
||||
/// Get or sets configuration for parallel lines to axis.
|
||||
/// </summary>
|
||||
public Separator Separator
|
||||
{
|
||||
get { return (Separator) GetValue(SeparatorProperty); }
|
||||
set { SetValue(SeparatorProperty, value); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The show labels property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShowLabelsProperty = DependencyProperty.Register(
|
||||
"ShowLabels", typeof (bool), typeof (Axis),
|
||||
new PropertyMetadata(default(bool), LabelsVisibilityChanged));
|
||||
/// <summary>
|
||||
/// Gets or sets if labels are shown in the axis.
|
||||
/// </summary>
|
||||
public bool ShowLabels
|
||||
{
|
||||
get { return (bool) GetValue(ShowLabelsProperty); }
|
||||
set { SetValue(ShowLabelsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The maximum value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register(
|
||||
"MaxValue", typeof (double), typeof (Axis),
|
||||
new PropertyMetadata(double.NaN, UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets axis max value, set it to double.NaN to make this property Auto, default value is double.NaN
|
||||
/// </summary>
|
||||
public double MaxValue
|
||||
{
|
||||
get { return (double) GetValue(MaxValueProperty); }
|
||||
set { SetValue(MaxValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The minimum value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MinValueProperty = DependencyProperty.Register(
|
||||
"MinValue", typeof (double), typeof (Axis),
|
||||
new PropertyMetadata(double.NaN, UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets axis min value, set it to double.NaN to make this property Auto, default value is double.NaN
|
||||
/// </summary>
|
||||
public double MinValue
|
||||
{
|
||||
get { return (double)GetValue(MinValueProperty); }
|
||||
set { SetValue(MinValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actual minimum value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The actual minimum value.
|
||||
/// </value>
|
||||
public double ActualMinValue
|
||||
{
|
||||
get { return Model.BotLimit; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actual maximum value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The actual maximum value.
|
||||
/// </value>
|
||||
public double ActualMaxValue
|
||||
{
|
||||
get { return Model.TopLimit; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The maximum range property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxRangeProperty = DependencyProperty.Register(
|
||||
"MaxRange", typeof(double), typeof(Axis), new PropertyMetadata(double.MaxValue));
|
||||
/// <summary>
|
||||
/// Gets or sets the max range this axis can display, useful to limit user zooming.
|
||||
/// </summary>
|
||||
public double MaxRange
|
||||
{
|
||||
get { return (double) GetValue(MaxRangeProperty); }
|
||||
set { SetValue(MaxRangeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The minimum range property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MinRangeProperty = DependencyProperty.Register(
|
||||
"MinRange", typeof(double), typeof(Axis), new PropertyMetadata(double.MinValue));
|
||||
/// <summary>
|
||||
/// Gets or sets the min range this axis can display, useful to limit user zooming.
|
||||
/// </summary>
|
||||
public double MinRange
|
||||
{
|
||||
get { return (double) GetValue(MinRangeProperty); }
|
||||
set { SetValue(MinRangeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The title property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
|
||||
"Title", typeof(string), typeof(Axis),
|
||||
new PropertyMetadata(null, UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets axis title, the title will be displayed only if this property is not null, default is null.
|
||||
/// </summary>
|
||||
public string Title
|
||||
{
|
||||
get { return (string)GetValue(TitleProperty); }
|
||||
set { SetValue(TitleProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PositionProperty = DependencyProperty.Register(
|
||||
"Position", typeof (AxisPosition), typeof (Axis),
|
||||
new PropertyMetadata(default(AxisPosition), UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets the axis position, default is Axis.Position.LeftBottom, when the axis is at Y and Position is LeftBottom, then axis will be placed at left, RightTop position will place it at Right, when the axis is at X and position LeftBottom, the axis will be placed at bottom, if position is RightTop then it will be placed at top.
|
||||
/// </summary>
|
||||
public AxisPosition Position
|
||||
{
|
||||
get { return (AxisPosition) GetValue(PositionProperty); }
|
||||
set { SetValue(PositionProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The is merged property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsMergedProperty = DependencyProperty.Register(
|
||||
"IsMerged", typeof (bool), typeof (Axis),
|
||||
new PropertyMetadata(default(bool), UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets if the axis labels should me placed inside the chart, this is useful to save some space.
|
||||
/// </summary>
|
||||
public bool IsMerged
|
||||
{
|
||||
get { return (bool) GetValue(IsMergedProperty); }
|
||||
set { SetValue(IsMergedProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The disable animations property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DisableAnimationsProperty = DependencyProperty.Register(
|
||||
"DisableAnimations", typeof (bool), typeof (Axis), new PropertyMetadata(default(bool), UpdateChart(true)));
|
||||
/// <summary>
|
||||
/// Gets or sets if the axis is animated.
|
||||
/// </summary>
|
||||
public bool DisableAnimations
|
||||
{
|
||||
get { return (bool) GetValue(DisableAnimationsProperty); }
|
||||
set { SetValue(DisableAnimationsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font family property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontFamilyProperty =
|
||||
DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(Axis),
|
||||
new PropertyMetadata(new FontFamily("Calibri")));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets labels font family, font to use for any label in this axis
|
||||
/// </summary>
|
||||
public FontFamily FontFamily
|
||||
{
|
||||
get { return (FontFamily)GetValue(FontFamilyProperty); }
|
||||
set { SetValue(FontFamilyProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font size property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontSizeProperty =
|
||||
DependencyProperty.Register("FontSize", typeof(double), typeof(Axis), new PropertyMetadata(11.0));
|
||||
/// <summary>
|
||||
/// Gets or sets labels font size
|
||||
/// </summary>
|
||||
public double FontSize
|
||||
{
|
||||
get { return (double)GetValue(FontSizeProperty); }
|
||||
set { SetValue(FontSizeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font weight property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontWeightProperty =
|
||||
DependencyProperty.Register("FontWeight", typeof(FontWeight), typeof(Axis),
|
||||
new PropertyMetadata(FontWeights.Normal));
|
||||
/// <summary>
|
||||
/// Gets or sets labels font weight
|
||||
/// </summary>
|
||||
public FontWeight FontWeight
|
||||
{
|
||||
get { return (FontWeight)GetValue(FontWeightProperty); }
|
||||
set { SetValue(FontWeightProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font style property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontStyleProperty =
|
||||
DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(Axis),
|
||||
new PropertyMetadata(FontStyles.Normal));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets labels font style
|
||||
/// </summary>
|
||||
public FontStyle FontStyle
|
||||
{
|
||||
get { return (FontStyle)GetValue(FontStyleProperty); }
|
||||
set { SetValue(FontStyleProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font stretch property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontStretchProperty =
|
||||
DependencyProperty.Register("FontStretch", typeof(FontStretch), typeof(Axis),
|
||||
new PropertyMetadata(FontStretches.Normal));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets labels font stretch
|
||||
/// </summary>
|
||||
public FontStretch FontStretch
|
||||
{
|
||||
get { return (FontStretch)GetValue(FontStretchProperty); }
|
||||
set { SetValue(FontStretchProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The foreground property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ForegroundProperty =
|
||||
DependencyProperty.Register("Foreground", typeof(Brush), typeof(Axis),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets labels text color.
|
||||
/// </summary>
|
||||
public Brush Foreground
|
||||
{
|
||||
get { return (Brush)GetValue(ForegroundProperty); }
|
||||
set { SetValue(ForegroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The labels rotation property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelsRotationProperty = DependencyProperty.Register(
|
||||
"LabelsRotation", typeof (double), typeof (Axis), new PropertyMetadata(default(double), UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets the labels rotation in the axis, the angle starts as a horizontal line, you can use any angle in degrees, even negatives.
|
||||
/// </summary>
|
||||
public double LabelsRotation
|
||||
{
|
||||
get { return (double) GetValue(LabelsRotationProperty); }
|
||||
set { SetValue(LabelsRotationProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The bar unit property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty BarUnitProperty = DependencyProperty.Register(
|
||||
"BarUnit", typeof(double), typeof(Axis), new PropertyMetadata(double.NaN));
|
||||
/// <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("PThis property was renamed, 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(double.NaN));
|
||||
/// <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>
|
||||
public static readonly DependencyProperty AxisOrientationProperty = DependencyProperty.Register(
|
||||
"AxisOrientation", typeof(AxisOrientation), typeof(Axis), new PropertyMetadata(default(AxisOrientation)));
|
||||
/// <summary>
|
||||
/// Gets or sets the element orientation ind the axis
|
||||
/// </summary>
|
||||
public AxisOrientation AxisOrientation
|
||||
{
|
||||
get { return (AxisOrientation) GetValue(AxisOrientationProperty); }
|
||||
internal set { SetValue(AxisOrientationProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
///<summary>
|
||||
/// Cleans this instance.
|
||||
/// </summary>
|
||||
public void Clean()
|
||||
{
|
||||
if (Model == null) return;
|
||||
Model.ClearSeparators();
|
||||
Model.Chart.View.RemoveFromView(TitleBlock);
|
||||
Sections.Clear();
|
||||
TitleBlock = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the separator.
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <param name="chart">The chart.</param>
|
||||
public virtual void RenderSeparator(SeparatorElementCore model, ChartCore chart)
|
||||
{
|
||||
AxisSeparatorElement ase;
|
||||
|
||||
if (model.View == null)
|
||||
{
|
||||
ase = new AxisSeparatorElement(model)
|
||||
{
|
||||
Line = BindALine(),
|
||||
TextBlock = BindATextBlock()
|
||||
};
|
||||
|
||||
model.View = ase;
|
||||
chart.View.AddToView(ase.Line);
|
||||
chart.View.AddToView(ase.TextBlock);
|
||||
Panel.SetZIndex(ase.Line, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ase = (AxisSeparatorElement) model.View;
|
||||
}
|
||||
|
||||
ase.Line.Visibility = !Separator.IsEnabled ? Visibility.Collapsed : Visibility.Visible;
|
||||
ase.TextBlock.Visibility = !ShowLabels ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the title.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
/// <param name="rotationAngle">The rotation angle.</param>
|
||||
/// <returns></returns>
|
||||
public CoreSize UpdateTitle(ChartCore chart, double rotationAngle = 0)
|
||||
{
|
||||
if (TitleBlock.Parent == null)
|
||||
{
|
||||
if (Math.Abs(rotationAngle) > 1)
|
||||
TitleBlock.RenderTransform = new RotateTransform(rotationAngle);
|
||||
|
||||
chart.View.AddToView(TitleBlock);
|
||||
}
|
||||
|
||||
FormattedTitle = new FormattedText(
|
||||
TitleBlock.Text,
|
||||
CultureInfo.CurrentUICulture,
|
||||
FlowDirection.LeftToRight,
|
||||
new Typeface(TitleBlock.FontFamily, TitleBlock.FontStyle, TitleBlock.FontWeight, TitleBlock.FontStretch),
|
||||
TitleBlock.FontSize, Brushes.Black);
|
||||
|
||||
return string.IsNullOrWhiteSpace(Title)
|
||||
? new CoreSize()
|
||||
: new CoreSize(TitleBlock.Width, FormattedTitle.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the title top.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
public void SetTitleTop(double value)
|
||||
{
|
||||
Canvas.SetTop(TitleBlock, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the title left.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
public void SetTitleLeft(double value)
|
||||
{
|
||||
Canvas.SetLeft(TitleBlock, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title left.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public double GetTitleLeft()
|
||||
{
|
||||
return Canvas.GetLeft(TitleBlock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tile top.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public double GetTileTop()
|
||||
{
|
||||
return Canvas.GetTop(TitleBlock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the label.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public CoreSize GetLabelSize()
|
||||
{
|
||||
return new CoreSize(FormattedTitle.Width, FormattedTitle.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ases the core element.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
public virtual AxisCore AsCoreElement(ChartCore chart, AxisOrientation source)
|
||||
{
|
||||
if (Model == null) Model = new AxisCore(this);
|
||||
|
||||
Model.ShowLabels = ShowLabels;
|
||||
Model.Chart = chart;
|
||||
Model.IsMerged = IsMerged;
|
||||
Model.Labels = Labels;
|
||||
Model.LabelFormatter = LabelFormatter;
|
||||
Model.MaxValue = MaxValue;
|
||||
Model.MinValue = MinValue;
|
||||
Model.Title = Title;
|
||||
Model.Position = Position;
|
||||
Model.Separator = Separator.AsCoreElement(Model, source);
|
||||
Model.DisableAnimations = DisableAnimations;
|
||||
Model.Sections = Sections.Select(x => x.AsCoreElement(Model, source)).ToList();
|
||||
|
||||
return Model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the range.
|
||||
/// </summary>
|
||||
/// <param name="min">The minimum.</param>
|
||||
/// <param name="max">The maximum.</param>
|
||||
public void SetRange(double min, double max)
|
||||
{
|
||||
var bMax = double.IsNaN(MaxValue) ? Model.TopLimit : MaxValue;
|
||||
var bMin = double.IsNaN(MinValue) ? Model.BotLimit : MinValue;
|
||||
|
||||
var nMax = double.IsNaN(MaxValue) ? Model.TopLimit : MaxValue;
|
||||
var nMin = double.IsNaN(MinValue) ? Model.BotLimit : MinValue;
|
||||
|
||||
var e = new RangeChangedEventArgs
|
||||
{
|
||||
Range = nMax - nMin,
|
||||
RightLimitChange = bMax - nMax,
|
||||
LeftLimitChange = bMin - nMin,
|
||||
Axis = this
|
||||
};
|
||||
|
||||
var pe = new PreviewRangeChangedEventArgs(e)
|
||||
{
|
||||
PreviewMaxValue = max,
|
||||
PreviewMinValue = min
|
||||
};
|
||||
OnPreviewRangeChanged(pe);
|
||||
|
||||
if (pe.Cancel) return;
|
||||
|
||||
MaxValue = max;
|
||||
MinValue = min;
|
||||
|
||||
Model.Chart.Updater.Run();
|
||||
|
||||
OnRangeChanged(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal TextBlock BindATextBlock()
|
||||
{
|
||||
var tb = new TextBlock();
|
||||
|
||||
tb.SetBinding(TextBlock.FontFamilyProperty,
|
||||
new Binding { Path = new PropertyPath(FontFamilyProperty), Source = this });
|
||||
tb.SetBinding(TextBlock.FontSizeProperty,
|
||||
new Binding { Path = new PropertyPath(FontSizeProperty), Source = this });
|
||||
tb.SetBinding(TextBlock.FontStretchProperty,
|
||||
new Binding { Path = new PropertyPath(FontStretchProperty), Source = this });
|
||||
tb.SetBinding(TextBlock.FontStyleProperty,
|
||||
new Binding { Path = new PropertyPath(FontStyleProperty), Source = this });
|
||||
tb.SetBinding(TextBlock.FontWeightProperty,
|
||||
new Binding { Path = new PropertyPath(FontWeightProperty), Source = this });
|
||||
tb.SetBinding(TextBlock.ForegroundProperty,
|
||||
new Binding { Path = new PropertyPath(ForegroundProperty), Source = this });
|
||||
|
||||
return tb;
|
||||
}
|
||||
|
||||
internal Line BindALine()
|
||||
{
|
||||
var l = new Line();
|
||||
|
||||
var s = Separator as Separator;
|
||||
if (s == null) return l;
|
||||
|
||||
l.SetBinding(Shape.StrokeProperty,
|
||||
new Binding {Path = new PropertyPath(Wpf.Separator.StrokeProperty), Source = s});
|
||||
l.SetBinding(Shape.StrokeDashArrayProperty,
|
||||
new Binding {Path = new PropertyPath(Wpf.Separator.StrokeDashArrayProperty), Source = s});
|
||||
l.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding {Path = new PropertyPath(Wpf.Separator.StrokeThicknessProperty), Source = s});
|
||||
l.SetBinding(VisibilityProperty,
|
||||
new Binding {Path = new PropertyPath(VisibilityProperty), Source = s});
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the chart.
|
||||
/// </summary>
|
||||
/// <param name="animate">if set to <c>true</c> [animate].</param>
|
||||
/// <param name="updateNow">if set to <c>true</c> [update now].</param>
|
||||
/// <returns></returns>
|
||||
protected static PropertyChangedCallback UpdateChart(bool animate = false, bool updateNow = false)
|
||||
{
|
||||
return (o, args) =>
|
||||
{
|
||||
var wpfAxis = o as Axis;
|
||||
if (wpfAxis == null) return;
|
||||
|
||||
if (wpfAxis.Model != null)
|
||||
wpfAxis.Model.Chart.Updater.Run(animate, updateNow);
|
||||
};
|
||||
}
|
||||
|
||||
private static void LabelsVisibilityChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
var axis = (Axis) dependencyObject;
|
||||
if (axis.Model == null) return;
|
||||
|
||||
foreach (var separator in axis.Model.CurrentSeparators)
|
||||
{
|
||||
var s = (AxisSeparatorElement) separator.View;
|
||||
s.TextBlock.Visibility = axis.ShowLabels
|
||||
? Visibility.Visible
|
||||
: Visibility.Collapsed;
|
||||
}
|
||||
|
||||
UpdateChart()(dependencyObject, dependencyPropertyChangedEventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:RangeChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="RangeChangedEventArgs"/> instance containing the event data.</param>
|
||||
protected void OnRangeChanged(RangeChangedEventArgs e)
|
||||
{
|
||||
if (RangeChanged != null)
|
||||
RangeChanged.Invoke(e);
|
||||
if (RangeChangedCommand != null && RangeChangedCommand.CanExecute(e))
|
||||
RangeChangedCommand.Execute(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:PreviewRangeChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="PreviewRangeChangedEventArgs"/> instance containing the event data.</param>
|
||||
protected void OnPreviewRangeChanged(PreviewRangeChangedEventArgs e)
|
||||
{
|
||||
if (PreviewRangeChanged != null)
|
||||
PreviewRangeChanged.Invoke(e);
|
||||
if (PreviewRangeChangedCommand != null && PreviewRangeChangedCommand.CanExecute(e))
|
||||
PreviewRangeChangedCommand.Execute(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
503
Others/Live-Charts-master/WpfView/AxisSection.cs
Normal file
503
Others/Live-Charts-master/WpfView/AxisSection.cs
Normal file
@@ -0,0 +1,503 @@
|
||||
//copyright(c) 2016 Alberto Rodriguez
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Helpers;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// An Axis section highlights values or ranges in a chart.
|
||||
/// </summary>
|
||||
public class AxisSection : FrameworkElement, IAxisSectionView
|
||||
{
|
||||
private readonly Rectangle _rectangle;
|
||||
private TextBlock _label;
|
||||
internal static AxisSection Dragging;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of AxisSection class
|
||||
/// </summary>
|
||||
public AxisSection()
|
||||
{
|
||||
_rectangle = new Rectangle();
|
||||
|
||||
_rectangle.MouseDown += (sender, args) =>
|
||||
{
|
||||
if (!Draggable) return;
|
||||
Dragging = this;
|
||||
args.Handled = true;
|
||||
Chart.Ldsp = null;
|
||||
};
|
||||
|
||||
SetCurrentValue(StrokeProperty, new SolidColorBrush(Color.FromRgb(131, 172, 191)));
|
||||
SetCurrentValue(FillProperty, new SolidColorBrush(Color.FromRgb(131, 172, 191)) {Opacity = .35});
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
}
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the model.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The model.
|
||||
/// </value>
|
||||
public AxisSectionCore Model { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The label property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(
|
||||
"Label", typeof(string), typeof(AxisSection), new PropertyMetadata(default(string)));
|
||||
/// <summary>
|
||||
/// Gets or sets the name, the title of the section, a visual element will be added to the chart if this property is not null.
|
||||
/// </summary>
|
||||
[Obsolete("Use a VisualElement instead")]
|
||||
public string Label
|
||||
{
|
||||
get { return (string)GetValue(LabelProperty); }
|
||||
set { SetValue(LabelProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FromValueProperty = DependencyProperty.Register(
|
||||
"FromValue", typeof(double), typeof(AxisSection),
|
||||
new PropertyMetadata(double.NaN, UpdateSection));
|
||||
/// <summary>
|
||||
/// Gets or sets the value where the section starts
|
||||
/// </summary>
|
||||
[Obsolete("This property will be removed in future versions, instead use Value and SectionWidth properties")]
|
||||
public double FromValue
|
||||
{
|
||||
get { return (double)GetValue(FromValueProperty); }
|
||||
set { SetValue(FromValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ToValueProperty = DependencyProperty.Register(
|
||||
"ToValue", typeof(double), typeof(AxisSection),
|
||||
new PropertyMetadata(double.NaN, UpdateSection));
|
||||
/// <summary>
|
||||
/// Gets or sets the value where the section ends
|
||||
/// </summary>
|
||||
[Obsolete("This property will be removed in future versions, instead use Value and SectionWidth properties")]
|
||||
public double ToValue
|
||||
{
|
||||
get { return (double)GetValue(ToValueProperty); }
|
||||
set { SetValue(ToValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
|
||||
"Value", typeof(double), typeof(AxisSection), new PropertyMetadata(default(double), UpdateSection));
|
||||
/// <summary>
|
||||
/// Gets or sets the value where the section is drawn
|
||||
/// </summary>
|
||||
public double Value
|
||||
{
|
||||
get { return (double) GetValue(ValueProperty); }
|
||||
set { SetValue(ValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The section width property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SectionWidthProperty = DependencyProperty.Register(
|
||||
"SectionWidth", typeof(double), typeof(AxisSection), new PropertyMetadata(default(double), UpdateSection));
|
||||
/// <summary>
|
||||
/// Gets or sets the section width
|
||||
/// </summary>
|
||||
public double SectionWidth
|
||||
{
|
||||
get { return (double) GetValue(SectionWidthProperty); }
|
||||
set { SetValue(SectionWidthProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The section offset property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SectionOffsetProperty = DependencyProperty.Register(
|
||||
"SectionOffset", typeof(double), typeof(AxisSection), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets the section offset.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The section offset.
|
||||
/// </value>
|
||||
public double SectionOffset
|
||||
{
|
||||
get { return (double) GetValue(SectionOffsetProperty); }
|
||||
set { SetValue(SectionOffsetProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stroke property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register(
|
||||
"Stroke", typeof(Brush), typeof(AxisSection), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets o sets the section stroke, the stroke brush will be used to draw the border of the section
|
||||
/// </summary>
|
||||
public Brush Stroke
|
||||
{
|
||||
get { return (Brush)GetValue(StrokeProperty); }
|
||||
set { SetValue(StrokeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fill property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FillProperty = DependencyProperty.Register(
|
||||
"Fill", typeof(Brush), typeof(AxisSection), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the section fill brush.
|
||||
/// </summary>
|
||||
public Brush Fill
|
||||
{
|
||||
get { return (Brush)GetValue(FillProperty); }
|
||||
set { SetValue(FillProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stroke thickness property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register(
|
||||
"StrokeThickness", typeof(double), typeof(AxisSection), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets the stroke thickness.
|
||||
/// </summary>
|
||||
public double StrokeThickness
|
||||
{
|
||||
get { return (double)GetValue(StrokeThicknessProperty); }
|
||||
set { SetValue(StrokeThicknessProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stroke dash array property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeDashArrayProperty = DependencyProperty.Register(
|
||||
"StrokeDashArray", typeof(DoubleCollection), typeof(AxisSection), new PropertyMetadata(default(DoubleCollection)));
|
||||
/// <summary>
|
||||
/// Gets or sets the stroke dash array collection, use this property to create dashed stroke sections
|
||||
/// </summary>
|
||||
public DoubleCollection StrokeDashArray
|
||||
{
|
||||
get { return (DoubleCollection)GetValue(StrokeDashArrayProperty); }
|
||||
set { SetValue(StrokeDashArrayProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The draggable property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DraggableProperty = DependencyProperty.Register(
|
||||
"Draggable", typeof(bool), typeof(AxisSection), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets if a user can drag the section
|
||||
/// </summary>
|
||||
public bool Draggable
|
||||
{
|
||||
get { return (bool) GetValue(DraggableProperty); }
|
||||
set { SetValue(DraggableProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The disable animations property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DisableAnimationsProperty = DependencyProperty.Register(
|
||||
"DisableAnimations", typeof(bool), typeof(AxisSection), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the section is animated
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [disable animations]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool DisableAnimations
|
||||
{
|
||||
get { return (bool) GetValue(DisableAnimationsProperty); }
|
||||
set { SetValue(DisableAnimationsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The data label property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DataLabelProperty = DependencyProperty.Register(
|
||||
"DataLabel", typeof(bool), typeof(AxisSection), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the section should display a label that displays its current value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [data label]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool DataLabel
|
||||
{
|
||||
get { return (bool) GetValue(DataLabelProperty); }
|
||||
set { SetValue(DataLabelProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The data label brush property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DataLabelForegroundProperty = DependencyProperty.Register(
|
||||
"DataLabelForeground", typeof(Brush), typeof(AxisSection), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the data label brush.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The label brush.
|
||||
/// </value>
|
||||
public Brush DataLabelForeground
|
||||
{
|
||||
get { return (Brush) GetValue(DataLabelForegroundProperty); }
|
||||
set { SetValue(DataLabelForegroundProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Draws the or move.
|
||||
/// </summary>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <param name="axis">The axis.</param>
|
||||
public void DrawOrMove(AxisOrientation source, int axis)
|
||||
{
|
||||
_rectangle.Fill = Fill;
|
||||
_rectangle.Stroke = Stroke;
|
||||
_rectangle.StrokeDashArray = StrokeDashArray;
|
||||
_rectangle.StrokeThickness = StrokeThickness;
|
||||
Panel.SetZIndex(_rectangle, Panel.GetZIndex(this));
|
||||
BindingOperations.SetBinding(_rectangle, VisibilityProperty,
|
||||
new Binding {Path = new PropertyPath(VisibilityProperty), Source = this});
|
||||
|
||||
var ax = source == AxisOrientation.X ? Model.Chart.AxisX[axis] : Model.Chart.AxisY[axis];
|
||||
var uw = ax.EvaluatesUnitWidth ? ChartFunctions.GetUnitWidth(source, Model.Chart, axis) / 2 : 0;
|
||||
|
||||
if (Parent == null)
|
||||
{
|
||||
_label = ((Axis) ax.View).BindATextBlock();
|
||||
_label.Padding = new Thickness(5, 2, 5, 2);
|
||||
Model.Chart.View.AddToView(this);
|
||||
Model.Chart.View.AddToDrawMargin(_rectangle);
|
||||
Model.Chart.View.AddToView(_label);
|
||||
_rectangle.Height = 0;
|
||||
_rectangle.Width = 0;
|
||||
Canvas.SetLeft(_rectangle, 0d);
|
||||
Canvas.SetTop(_rectangle, Model.Chart.DrawMargin.Height);
|
||||
#region Obsolete
|
||||
Canvas.SetTop(_label, Model.Chart.DrawMargin.Height);
|
||||
Canvas.SetLeft(_label, 0d);
|
||||
#endregion
|
||||
}
|
||||
|
||||
#pragma warning disable 618
|
||||
var from = ChartFunctions.ToDrawMargin(double.IsNaN(FromValue) ? Value + SectionOffset : FromValue, source, Model.Chart, axis) + uw;
|
||||
#pragma warning restore 618
|
||||
#pragma warning disable 618
|
||||
var to = ChartFunctions.ToDrawMargin(double.IsNaN(ToValue) ? Value + SectionOffset + SectionWidth : ToValue, source, Model.Chart, axis) + uw;
|
||||
#pragma warning restore 618
|
||||
|
||||
if (from > to)
|
||||
{
|
||||
var temp = to;
|
||||
to = from;
|
||||
from = temp;
|
||||
}
|
||||
|
||||
var anSpeed = Model.Chart.View.AnimationsSpeed;
|
||||
|
||||
if (DataLabel)
|
||||
{
|
||||
if (DataLabelForeground != null) _label.Foreground = DataLabelForeground;
|
||||
_label.UpdateLayout();
|
||||
_label.Background = Stroke ?? Fill;
|
||||
PlaceLabel(ax.GetFormatter()(Value), ax, source);
|
||||
}
|
||||
|
||||
if (source == AxisOrientation.X)
|
||||
{
|
||||
var w = to - from;
|
||||
w = StrokeThickness > w ? StrokeThickness : w;
|
||||
|
||||
Canvas.SetTop(_rectangle, 0);
|
||||
_rectangle.Height = Model.Chart.DrawMargin.Height;
|
||||
|
||||
if (Model.Chart.View.DisableAnimations || DisableAnimations)
|
||||
{
|
||||
_rectangle.Width = w > 0 ? w : 0;
|
||||
Canvas.SetLeft(_rectangle, from - StrokeThickness/2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_rectangle.BeginAnimation(WidthProperty, new DoubleAnimation(w > 0 ? w : 0, anSpeed));
|
||||
_rectangle.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(from - StrokeThickness / 2, anSpeed));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var h = to - from;
|
||||
h = StrokeThickness > h ? StrokeThickness : h;
|
||||
|
||||
Canvas.SetLeft(_rectangle, 0d);
|
||||
_rectangle.Width = Model.Chart.DrawMargin.Width;
|
||||
|
||||
if (Model.Chart.View.DisableAnimations || DisableAnimations)
|
||||
{
|
||||
Canvas.SetTop(_rectangle, from - StrokeThickness/2);
|
||||
_rectangle.Height = h > 0 ? h : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rectangle.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(from, anSpeed));
|
||||
_rectangle.BeginAnimation(HeightProperty, new DoubleAnimation(h, anSpeed));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes this instance.
|
||||
/// </summary>
|
||||
public void Remove()
|
||||
{
|
||||
Model.Chart.View.RemoveFromView(this);
|
||||
Model.Chart.View.RemoveFromDrawMargin(_rectangle);
|
||||
Model.Chart.View.RemoveFromDrawMargin(_label);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ases the core element.
|
||||
/// </summary>
|
||||
/// <param name="axis">The axis.</param>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
public AxisSectionCore AsCoreElement(AxisCore axis, AxisOrientation source)
|
||||
{
|
||||
var model = new AxisSectionCore(this, axis.Chart);
|
||||
model.View.Model = model;
|
||||
return model;
|
||||
}
|
||||
|
||||
private static void UpdateSection(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
var section = (AxisSection) dependencyObject;
|
||||
|
||||
if (section.Model != null && section.Model.Chart != null)
|
||||
{
|
||||
if (!section.Model.Chart.AreComponentsLoaded) return;
|
||||
section.DrawOrMove(section.Model.Source, section.Model.AxisIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaceLabel(string text, AxisCore axis, AxisOrientation source)
|
||||
{
|
||||
_label.Text = text;
|
||||
|
||||
var formattedText = new FormattedText(
|
||||
_label.Text,
|
||||
CultureInfo.CurrentUICulture,
|
||||
FlowDirection.LeftToRight,
|
||||
new Typeface(_label.FontFamily, _label.FontStyle, _label.FontWeight, _label.FontStretch),
|
||||
_label.FontSize, Brushes.Black);
|
||||
|
||||
var transform = new LabelEvaluation(axis.View.LabelsRotation,
|
||||
formattedText.Width + 10, formattedText.Height, axis, source);
|
||||
|
||||
_label.RenderTransform = Math.Abs(transform.LabelAngle) > 1
|
||||
? new RotateTransform(transform.LabelAngle)
|
||||
: null;
|
||||
|
||||
var toLine = ChartFunctions.ToPlotArea(Value + SectionOffset + SectionWidth * .5, source, Model.Chart,
|
||||
axis);
|
||||
|
||||
var direction = source == AxisOrientation.X ? 1 : -1;
|
||||
|
||||
toLine += axis.EvaluatesUnitWidth ? direction * ChartFunctions.GetUnitWidth(source, Model.Chart, axis) / 2 : 0;
|
||||
var toLabel = toLine + transform.GetOffsetBySource(source);
|
||||
|
||||
var chart = Model.Chart;
|
||||
|
||||
if (axis.IsMerged)
|
||||
{
|
||||
const double padding = 4;
|
||||
|
||||
if (source == AxisOrientation.Y)
|
||||
{
|
||||
if (toLabel + transform.ActualHeight >
|
||||
chart.DrawMargin.Top + chart.DrawMargin.Height)
|
||||
toLabel -= transform.ActualHeight + padding;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (toLabel + transform.ActualWidth >
|
||||
chart.DrawMargin.Left + chart.DrawMargin.Width)
|
||||
toLabel -= transform.ActualWidth + padding;
|
||||
}
|
||||
}
|
||||
|
||||
var labelTab = axis.Tab;
|
||||
labelTab += transform.GetOffsetBySource(source.Invert());
|
||||
|
||||
if (source == AxisOrientation.Y)
|
||||
{
|
||||
labelTab += 8 * (axis.Position == AxisPosition.LeftBottom ? 1 : -1);
|
||||
|
||||
if (Model.View.DisableAnimations || DisableAnimations)
|
||||
{
|
||||
Canvas.SetLeft(_label, labelTab);
|
||||
Canvas.SetTop(_label, toLabel);
|
||||
return;
|
||||
}
|
||||
|
||||
_label.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
|
||||
_label.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(labelTab, chart.View.AnimationsSpeed));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Model.View.DisableAnimations || DisableAnimations)
|
||||
{
|
||||
Canvas.SetLeft(_label, toLabel);
|
||||
Canvas.SetTop(_label, labelTab);
|
||||
return;
|
||||
}
|
||||
|
||||
_label.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
|
||||
_label.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(labelTab, chart.View.AnimationsSpeed));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Others/Live-Charts-master/WpfView/AxisWindowCollection.cs
Normal file
21
Others/Live-Charts-master/WpfView/AxisWindowCollection.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using LiveCharts.Helpers;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class AxisWindowCollection : NoisyCollection<AxisWindow>
|
||||
{
|
||||
public AxisWindowCollection()
|
||||
{
|
||||
NoisyCollectionChanged += OnNoisyCollectionChanged;
|
||||
}
|
||||
|
||||
private void OnNoisyCollectionChanged(IEnumerable<AxisWindow> oldItems, IEnumerable<AxisWindow> newItems)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
242
Others/Live-Charts-master/WpfView/CandleSeries.cs
Normal file
242
Others/Live-Charts-master/WpfView/CandleSeries.cs
Normal file
@@ -0,0 +1,242 @@
|
||||
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.SeriesAlgorithms;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
using LiveCharts.Wpf.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The Candle series defines a financial series, add this series to a cartesian chart
|
||||
/// </summary>
|
||||
public class CandleSeries : Series, IFinancialSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of OhclSeries class
|
||||
/// </summary>
|
||||
public CandleSeries()
|
||||
{
|
||||
Model = new CandleAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of OhclSeries class with a given mapper
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public CandleSeries(object configuration)
|
||||
{
|
||||
Model = new CandleAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The maximum column width property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxColumnWidthProperty = DependencyProperty.Register(
|
||||
"MaxColumnWidth", typeof (double), typeof (CandleSeries), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum with of a point, a point will be capped to this width.
|
||||
/// </summary>
|
||||
public double MaxColumnWidth
|
||||
{
|
||||
get { return (double) GetValue(MaxColumnWidthProperty); }
|
||||
set { SetValue(MaxColumnWidthProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The increase brush property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IncreaseBrushProperty = DependencyProperty.Register(
|
||||
"IncreaseBrush", typeof (Brush), typeof (CandleSeries), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the brush of the point when close value is grater than open value
|
||||
/// </summary>
|
||||
public Brush IncreaseBrush
|
||||
{
|
||||
get { return (Brush) GetValue(IncreaseBrushProperty); }
|
||||
set { SetValue(IncreaseBrushProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The decrease brush property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DecreaseBrushProperty = DependencyProperty.Register(
|
||||
"DecreaseBrush", typeof (Brush), typeof (CandleSeries), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the brush of the point when close value is less than open value
|
||||
/// </summary>
|
||||
public Brush DecreaseBrush
|
||||
{
|
||||
get { return (Brush) GetValue(DecreaseBrushProperty); }
|
||||
set { SetValue(DecreaseBrushProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The coloring rules property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ColoringRulesProperty = DependencyProperty.Register(
|
||||
"ColoringRules", typeof(IList<FinancialColoringRule>), typeof(CandleSeries), new PropertyMetadata(default(IList<FinancialColoringRule>)));
|
||||
/// <summary>
|
||||
/// Gets or sets the coloring rules, the coloring rules allows you to customize Stroke and Fill properties according to your needs, the first rule in this collection that returns true, will decide the Stroke/Fill of every point. If this property is not null (default is null), CandleSeries Fill/Stroke will be based on DecreaseBrush and IncreaseBrush properties.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The coloring rules.
|
||||
/// </value>
|
||||
public IList<FinancialColoringRule> ColoringRules
|
||||
{
|
||||
get { return (IList<FinancialColoringRule>) GetValue(ColoringRulesProperty); }
|
||||
set { SetValue(ColoringRulesProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// This method runs when the update starts
|
||||
/// </summary>
|
||||
public override void OnSeriesUpdateStart()
|
||||
{
|
||||
//do nothing on updateStart
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point view.
|
||||
/// </summary>
|
||||
/// <param name="point">The point.</param>
|
||||
/// <param name="label">The label.</param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (CandlePointView)point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new CandlePointView
|
||||
{
|
||||
IsNew = true,
|
||||
HighToLowLine = new Line(),
|
||||
OpenToCloseRectangle = new Rectangle()
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HighToLowLine);
|
||||
Model.Chart.View.AddToDrawMargin(pbv.OpenToCloseRectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HighToLowLine);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.OpenToCloseRectangle);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
var i = Panel.GetZIndex(this);
|
||||
|
||||
pbv.HighToLowLine.StrokeThickness = StrokeThickness;
|
||||
pbv.HighToLowLine.StrokeDashArray = StrokeDashArray;
|
||||
pbv.HighToLowLine.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.HighToLowLine, i);
|
||||
|
||||
pbv.OpenToCloseRectangle.Fill = Fill;
|
||||
pbv.OpenToCloseRectangle.StrokeThickness = StrokeThickness;
|
||||
pbv.OpenToCloseRectangle.Stroke = Stroke;
|
||||
pbv.OpenToCloseRectangle.StrokeDashArray = StrokeDashArray;
|
||||
pbv.OpenToCloseRectangle.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.HighToLowLine, i);
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(StrokeThicknessProperty, 1d);
|
||||
SetCurrentValue(MaxColumnWidthProperty, 35d);
|
||||
SetCurrentValue(IncreaseBrushProperty, new SolidColorBrush(Color.FromRgb(76, 174, 80)));
|
||||
SetCurrentValue(DecreaseBrushProperty, new SolidColorBrush(Color.FromRgb(238, 83, 80)));
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x =>
|
||||
string.Format("O: {0}, H: {1}, L: {2} C: {3}", x.Open, x.High, x.Low, x.Close);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
77
Others/Live-Charts-master/WpfView/CartesianChart.cs
Normal file
77
Others/Live-Charts-master/WpfView/CartesianChart.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The Cartesian chart can plot any series with x and y coordinates
|
||||
/// </summary>
|
||||
public class CartesianChart : Chart, ICartesianChart
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of CartesianChart class
|
||||
/// </summary>
|
||||
public CartesianChart()
|
||||
{
|
||||
var freq = DisableAnimations ? TimeSpan.FromMilliseconds(10) : AnimationsSpeed;
|
||||
var updater = new Components.ChartUpdater(freq);
|
||||
ChartCoreModel = new CartesianChartCore(this, updater);
|
||||
|
||||
SetCurrentValue(SeriesProperty,
|
||||
DesignerProperties.GetIsInDesignMode(this)
|
||||
? GetDesignerModeCollection()
|
||||
: new SeriesCollection());
|
||||
|
||||
SetCurrentValue(VisualElementsProperty, new VisualElementsCollection());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The visual elements property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty VisualElementsProperty = DependencyProperty.Register(
|
||||
"VisualElements", typeof (VisualElementsCollection), typeof (CartesianChart),
|
||||
new PropertyMetadata(default(VisualElementsCollection), OnVisualCollectionChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the collection of visual elements in the chart, a visual element display another UiElement in the chart.
|
||||
/// </summary>
|
||||
public VisualElementsCollection VisualElements
|
||||
{
|
||||
get { return (VisualElementsCollection) GetValue(VisualElementsProperty); }
|
||||
set { SetValue(VisualElementsProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnVisualCollectionChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
var chart = (CartesianChart)dependencyObject;
|
||||
|
||||
if (chart.VisualElements != null) chart.VisualElements.Chart = chart.Model;
|
||||
}
|
||||
}
|
||||
}
|
||||
1474
Others/Live-Charts-master/WpfView/Charts/Base/Chart.cs
Normal file
1474
Others/Live-Charts-master/WpfView/Charts/Base/Chart.cs
Normal file
File diff suppressed because it is too large
Load Diff
34
Others/Live-Charts-master/WpfView/ColorsCollection.cs
Normal file
34
Others/Live-Charts-master/WpfView/ColorsCollection.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ColorsCollection : List<Color>
|
||||
{
|
||||
}
|
||||
}
|
||||
225
Others/Live-Charts-master/WpfView/ColumnSeries.cs
Normal file
225
Others/Live-Charts-master/WpfView/ColumnSeries.cs
Normal file
@@ -0,0 +1,225 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Use the column series to plot horizontal bars in a cartesian chart
|
||||
/// </summary>
|
||||
public class ColumnSeries : Series, IColumnSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ColumnSeries class
|
||||
/// </summary>
|
||||
public ColumnSeries()
|
||||
{
|
||||
Model = new ColumnAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ColumnSeries class, using a given mapper
|
||||
/// </summary>
|
||||
public ColumnSeries(object configuration)
|
||||
{
|
||||
Model = new ColumnAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The maximum column width property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxColumnWidthProperty = DependencyProperty.Register(
|
||||
"MaxColumnWidth", typeof (double), typeof (ColumnSeries), new PropertyMetadata(35d));
|
||||
/// <summary>
|
||||
/// Gets or sets the MaxColumnWidht in pixels, the column width will be capped at this value.
|
||||
/// </summary>
|
||||
public double MaxColumnWidth
|
||||
{
|
||||
get { return (double) GetValue(MaxColumnWidthProperty); }
|
||||
set { SetValue(MaxColumnWidthProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The column padding property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ColumnPaddingProperty = DependencyProperty.Register(
|
||||
"ColumnPadding", typeof (double), typeof (ColumnSeries), new PropertyMetadata(2d));
|
||||
/// <summary>
|
||||
/// Gets or sets the padding between the columns in the series.
|
||||
/// </summary>
|
||||
public double ColumnPadding
|
||||
{
|
||||
get { return (double) GetValue(ColumnPaddingProperty); }
|
||||
set { SetValue(ColumnPaddingProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The labels position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelsPositionProperty = DependencyProperty.Register(
|
||||
"LabelsPosition", typeof (BarLabelPosition), typeof (ColumnSeries),
|
||||
new PropertyMetadata(default(BarLabelPosition), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets where the label is placed
|
||||
/// </summary>
|
||||
public BarLabelPosition LabelsPosition
|
||||
{
|
||||
get { return (BarLabelPosition) GetValue(LabelsPositionProperty); }
|
||||
set { SetValue(LabelsPositionProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The shares position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SharesPositionProperty = DependencyProperty.Register(
|
||||
"SharesPosition", typeof(bool), typeof(ColumnSeries), new PropertyMetadata(true));
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this column shares space with all the column series in the same position
|
||||
/// </summary>
|
||||
public bool SharesPosition
|
||||
{
|
||||
get { return (bool) GetValue(SharesPositionProperty); }
|
||||
set { SetValue(SharesPositionProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (ColumnPointView) point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new ColumnPointView
|
||||
{
|
||||
IsNew = true,
|
||||
Rectangle = new Rectangle(),
|
||||
Data = new CoreRectangle()
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Rectangle);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
pbv.Rectangle.Fill = Fill;
|
||||
pbv.Rectangle.StrokeThickness = StrokeThickness;
|
||||
pbv.Rectangle.Stroke = Stroke;
|
||||
pbv.Rectangle.StrokeDashArray = StrokeDashArray;
|
||||
|
||||
pbv.Rectangle.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.Rectangle, Panel.GetZIndex(this));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
if (point.Stroke != null) pbv.Rectangle.Stroke = (Brush)point.Stroke;
|
||||
if (point.Fill != null) pbv.Rectangle.Fill = (Brush)point.Fill;
|
||||
|
||||
pbv.LabelPosition = LabelsPosition;
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
SetCurrentValue(MaxColumnWidthProperty, 35d);
|
||||
SetCurrentValue(ColumnPaddingProperty, 2d);
|
||||
SetCurrentValue(LabelsPositionProperty, BarLabelPosition.Top);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Wpf.Components
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="LiveCharts.Definitions.Charts.ISeparatorElementView" />
|
||||
public class AxisSeparatorElement : ISeparatorElementView
|
||||
{
|
||||
private readonly SeparatorElementCore _model;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AxisSeparatorElement"/> class.
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
public AxisSeparatorElement(SeparatorElementCore model)
|
||||
{
|
||||
_model = model;
|
||||
}
|
||||
|
||||
internal TextBlock TextBlock { get; set; }
|
||||
internal Line Line { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the label model.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The label model.
|
||||
/// </value>
|
||||
public LabelEvaluation LabelModel { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the model.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The model.
|
||||
/// </value>
|
||||
public SeparatorElementCore Model
|
||||
{
|
||||
get { return _model; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the label.
|
||||
/// </summary>
|
||||
/// <param name="text">The text.</param>
|
||||
/// <param name="axis">The axis.</param>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
|
||||
{
|
||||
TextBlock.Text = text;
|
||||
|
||||
var formattedText = new FormattedText(
|
||||
TextBlock.Text,
|
||||
CultureInfo.CurrentUICulture,
|
||||
FlowDirection.LeftToRight,
|
||||
new Typeface(TextBlock.FontFamily, TextBlock.FontStyle, TextBlock.FontWeight, TextBlock.FontStretch),
|
||||
TextBlock.FontSize, Brushes.Black);
|
||||
|
||||
var transform = new LabelEvaluation(axis.View.LabelsRotation,
|
||||
formattedText.Width, formattedText.Height, axis, source);
|
||||
|
||||
TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
|
||||
? new RotateTransform(transform.LabelAngle)
|
||||
: null;
|
||||
|
||||
LabelModel = transform;
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the specified chart.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
public void Clear(IChartView chart)
|
||||
{
|
||||
chart.RemoveFromView(TextBlock);
|
||||
chart.RemoveFromView(Line);
|
||||
TextBlock = null;
|
||||
Line = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places the specified chart.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
/// <param name="axis">The axis.</param>
|
||||
/// <param name="direction">The direction.</param>
|
||||
/// <param name="axisIndex">Index of the axis.</param>
|
||||
/// <param name="toLabel">To label.</param>
|
||||
/// <param name="toLine">To line.</param>
|
||||
/// <param name="tab">The tab.</param>
|
||||
public void Place(ChartCore chart, AxisCore axis, AxisOrientation direction, int axisIndex,
|
||||
double toLabel, double toLine, double tab)
|
||||
{
|
||||
if (direction == AxisOrientation.Y)
|
||||
{
|
||||
Line.X1 = chart.DrawMargin.Left;
|
||||
Line.X2 = chart.DrawMargin.Left + chart.DrawMargin.Width;
|
||||
Line.Y1 = toLine;
|
||||
Line.Y2 = toLine;
|
||||
|
||||
Canvas.SetLeft(TextBlock, tab);
|
||||
Canvas.SetTop(TextBlock, toLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Line.X1 = toLine;
|
||||
Line.X2 = toLine;
|
||||
Line.Y1 = chart.DrawMargin.Top;
|
||||
Line.Y2 = chart.DrawMargin.Top + chart.DrawMargin.Height;
|
||||
|
||||
Canvas.SetLeft(TextBlock, toLabel);
|
||||
Canvas.SetTop(TextBlock, tab);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified chart.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
public void Remove(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromView(TextBlock);
|
||||
chart.View.RemoveFromView(Line);
|
||||
TextBlock = null;
|
||||
Line = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the specified chart.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
/// <param name="axis">The axis.</param>
|
||||
/// <param name="direction">The direction.</param>
|
||||
/// <param name="axisIndex">Index of the axis.</param>
|
||||
/// <param name="toLabel">To label.</param>
|
||||
/// <param name="toLine">To line.</param>
|
||||
/// <param name="tab">The tab.</param>
|
||||
public void Move(ChartCore chart, AxisCore axis, AxisOrientation direction, int axisIndex, double toLabel, double toLine, double tab)
|
||||
{
|
||||
if (direction == AxisOrientation.Y)
|
||||
{
|
||||
Line.BeginAnimation(Line.X1Property,
|
||||
new DoubleAnimation(chart.DrawMargin.Left, chart.View.AnimationsSpeed));
|
||||
Line.BeginAnimation(Line.X2Property,
|
||||
new DoubleAnimation(chart.DrawMargin.Left + chart.DrawMargin.Width, chart.View.AnimationsSpeed));
|
||||
Line.BeginAnimation(Line.Y1Property,
|
||||
new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
|
||||
Line.BeginAnimation(Line.Y2Property,
|
||||
new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
|
||||
|
||||
TextBlock.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
|
||||
TextBlock.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(tab, chart.View.AnimationsSpeed));
|
||||
}
|
||||
else
|
||||
{
|
||||
Line.BeginAnimation(Line.X1Property,
|
||||
new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
|
||||
Line.BeginAnimation(Line.X2Property,
|
||||
new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
|
||||
Line.BeginAnimation(Line.Y1Property,
|
||||
new DoubleAnimation(chart.DrawMargin.Top, chart.View.AnimationsSpeed));
|
||||
Line.BeginAnimation(Line.Y2Property,
|
||||
new DoubleAnimation(chart.DrawMargin.Top + chart.DrawMargin.Height, chart.View.AnimationsSpeed));
|
||||
|
||||
TextBlock.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
|
||||
TextBlock.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(tab, chart.View.AnimationsSpeed));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fades the in.
|
||||
/// </summary>
|
||||
/// <param name="axis">The axis.</param>
|
||||
/// <param name="chart">The chart.</param>
|
||||
public void FadeIn(AxisCore axis, ChartCore chart)
|
||||
{
|
||||
if (TextBlock.Visibility != Visibility.Collapsed)
|
||||
TextBlock.BeginAnimation(UIElement.OpacityProperty,
|
||||
new DoubleAnimation(0, 1, chart.View.AnimationsSpeed));
|
||||
|
||||
if (Line.Visibility != Visibility.Collapsed)
|
||||
Line.BeginAnimation(UIElement.OpacityProperty,
|
||||
new DoubleAnimation(0, 1, chart.View.AnimationsSpeed));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fades the out and remove.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
public void FadeOutAndRemove(ChartCore chart)
|
||||
{
|
||||
if (TextBlock.Visibility == Visibility.Collapsed &&
|
||||
Line.Visibility == Visibility.Collapsed) return;
|
||||
|
||||
var anim = new DoubleAnimation
|
||||
{
|
||||
From = 1,
|
||||
To = 0,
|
||||
Duration = chart.View.AnimationsSpeed
|
||||
};
|
||||
|
||||
var dispatcher = ((Chart) chart.View).Dispatcher;
|
||||
anim.Completed += (sender, args) =>
|
||||
{
|
||||
dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
chart.View.RemoveFromView(TextBlock);
|
||||
chart.View.RemoveFromView(Line);
|
||||
}));
|
||||
};
|
||||
|
||||
TextBlock.BeginAnimation(UIElement.OpacityProperty, anim);
|
||||
Line.BeginAnimation(UIElement.OpacityProperty,
|
||||
new DoubleAnimation(1, 0, chart.View.AnimationsSpeed));
|
||||
}
|
||||
}
|
||||
}
|
||||
97
Others/Live-Charts-master/WpfView/Components/ChartUpdater.cs
Normal file
97
Others/Live-Charts-master/WpfView/Components/ChartUpdater.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Threading;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Wpf.Components
|
||||
{
|
||||
internal class ChartUpdater : LiveCharts.ChartUpdater
|
||||
{
|
||||
public ChartUpdater(TimeSpan frequency)
|
||||
{
|
||||
Timer = new DispatcherTimer {Interval = frequency};
|
||||
|
||||
Timer.Tick += OnTimerOnTick;
|
||||
Freq = frequency;
|
||||
}
|
||||
|
||||
public DispatcherTimer Timer { get; set; }
|
||||
private bool RequiresRestart { get; set; }
|
||||
private TimeSpan Freq { get; set; }
|
||||
|
||||
public override void Run(bool restartView = false, bool updateNow = false)
|
||||
{
|
||||
if (Timer == null)
|
||||
{
|
||||
Timer = new DispatcherTimer {Interval = Freq};
|
||||
Timer.Tick += OnTimerOnTick;
|
||||
IsUpdating = false;
|
||||
}
|
||||
|
||||
if (updateNow)
|
||||
{
|
||||
UpdaterTick(restartView, true);
|
||||
return;
|
||||
}
|
||||
|
||||
RequiresRestart = restartView || RequiresRestart;
|
||||
if (IsUpdating) return;
|
||||
|
||||
IsUpdating = true;
|
||||
Timer.Start();
|
||||
}
|
||||
|
||||
public override void UpdateFrequency(TimeSpan freq)
|
||||
{
|
||||
Timer.Interval = freq;
|
||||
}
|
||||
|
||||
public void OnTimerOnTick(object sender, EventArgs args)
|
||||
{
|
||||
UpdaterTick(RequiresRestart, false);
|
||||
}
|
||||
|
||||
private void UpdaterTick(bool restartView, bool force)
|
||||
{
|
||||
var wpfChart = (Chart) Chart.View;
|
||||
|
||||
if (!force && !wpfChart.IsVisible && !wpfChart.IsMocked) return;
|
||||
|
||||
Chart.ControlSize = wpfChart.IsMocked
|
||||
? wpfChart.Model.ControlSize
|
||||
: new CoreSize(wpfChart.ActualWidth, wpfChart.ActualHeight);
|
||||
|
||||
Timer.Stop();
|
||||
Update(restartView, force);
|
||||
IsUpdating = false;
|
||||
|
||||
RequiresRestart = false;
|
||||
|
||||
wpfChart.ChartUpdated();
|
||||
wpfChart.PrepareScrolBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
68
Others/Live-Charts-master/WpfView/Components/Converters.cs
Normal file
68
Others/Live-Charts-master/WpfView/Components/Converters.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//copyright(c) 2016 Greg Dennis & Alberto Rodriguez
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace LiveCharts.Wpf.Components
|
||||
{
|
||||
internal class SerieConverter : IValueConverter
|
||||
{
|
||||
public static SerieConverter Instance { get; set; }
|
||||
|
||||
static SerieConverter()
|
||||
{
|
||||
Instance = new SerieConverter();
|
||||
}
|
||||
private SerieConverter() { }
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var series = value as IEnumerable<Series>;
|
||||
if (series != null)
|
||||
return series.Select(x => new SeriesViewModel
|
||||
{
|
||||
|
||||
});
|
||||
|
||||
var serie = value as Series;
|
||||
if (serie != null)
|
||||
return new SeriesViewModel
|
||||
{
|
||||
Title = serie.Title,
|
||||
Stroke = serie.Stroke,
|
||||
Fill = serie.Fill,
|
||||
PointGeometry = serie.PointGeometry ?? Geometry.Parse("M 0,0.5 h 1,0.5 Z")
|
||||
};
|
||||
|
||||
return value;
|
||||
}
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System.Xml;
|
||||
|
||||
namespace LiveCharts.Wpf.Components
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class DefaultXamlReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the specified type.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DataTemplate DataLabelTemplate()
|
||||
{
|
||||
var stringReader = new StringReader(
|
||||
@"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
|
||||
<TextBlock Text=""{Binding FormattedText}""></TextBlock>
|
||||
</DataTemplate>");
|
||||
|
||||
var xmlReader = XmlReader.Create(stringReader);
|
||||
return XamlReader.Load(xmlReader) as DataTemplate;
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Others/Live-Charts-master/WpfView/Components/IFondeable.cs
Normal file
40
Others/Live-Charts-master/WpfView/Components/IFondeable.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace LiveCharts.Wpf.Components
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public interface IFondeable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the point foreground.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The point foreground.
|
||||
/// </value>
|
||||
Brush PointForeground { get; }
|
||||
}
|
||||
}
|
||||
48
Others/Live-Charts-master/WpfView/Components/ThreadAccess.cs
Normal file
48
Others/Live-Charts-master/WpfView/Components/ThreadAccess.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace LiveCharts.Wpf.Components
|
||||
{
|
||||
|
||||
// This is a workaround to prevent a possible threading issue
|
||||
// LiveChart was designed to be easy to use, the current design
|
||||
// avoids the usage of DataTemplates, instead we use the same object (UIElement)
|
||||
// since UI elements are running the UI thread, it is possible that
|
||||
// when we try to modify a property in a UIElement, i.e. the labels of an axis,
|
||||
// we can't, well we can but we need to use the UI dispatcher.
|
||||
|
||||
internal static class ThreadAccess
|
||||
{
|
||||
public static T Resolve<T>(DependencyObject dependencyObject,
|
||||
DependencyProperty dependencyProperty)
|
||||
{
|
||||
if (dependencyObject.Dispatcher.CheckAccess())
|
||||
return (T) dependencyObject.GetValue(dependencyProperty);
|
||||
|
||||
return (T) dependencyObject.Dispatcher.Invoke(
|
||||
new Func<T>(() => (T) dependencyObject.GetValue(dependencyProperty)));
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Others/Live-Charts-master/WpfView/Components/TooltipDto.cs
Normal file
76
Others/Live-Charts-master/WpfView/Components/TooltipDto.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace LiveCharts.Wpf.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// A tooltip element data transfer object
|
||||
/// </summary>
|
||||
public class TooltipDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the series.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The series.
|
||||
/// </value>
|
||||
public Series Series { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the index.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The index.
|
||||
/// </value>
|
||||
public int Index { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the stroke.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The stroke.
|
||||
/// </value>
|
||||
public Brush Stroke { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the fill.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The fill.
|
||||
/// </value>
|
||||
public Brush Fill { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the point.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The point.
|
||||
/// </value>
|
||||
public ChartPoint Point { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The value.
|
||||
/// </value>
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
113
Others/Live-Charts-master/WpfView/Converters/TypeConverters.cs
Normal file
113
Others/Live-Charts-master/WpfView/Converters/TypeConverters.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//copyright(c) 2016 Greg Dennis & Alberto Rodríguez
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using LiveCharts.Helpers;
|
||||
|
||||
namespace LiveCharts.Wpf.Converters
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.ComponentModel.TypeConverter" />
|
||||
public class StringCollectionConverter : TypeConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
|
||||
/// <param name="sourceType">A <see cref="T:System.Type" /> that represents the type you want to convert from.</param>
|
||||
/// <returns>
|
||||
/// true if this converter can perform the conversion; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof (string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the given object to the type of this converter, using the specified context and culture information.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
|
||||
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param>
|
||||
/// <param name="value">The <see cref="T:System.Object" /> to convert.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="T:System.Object" /> that represents the converted value.
|
||||
/// </returns>
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
var valueString = value as string;
|
||||
if (valueString != null)
|
||||
{
|
||||
return valueString.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(x => x.Trim())
|
||||
.ToArray();
|
||||
}
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.ComponentModel.TypeConverter" />
|
||||
public class NumericChartValuesConverter : TypeConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
|
||||
/// <param name="sourceType">A <see cref="T:System.Type" /> that represents the type you want to convert from.</param>
|
||||
/// <returns>
|
||||
/// true if this converter can perform the conversion; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the given object to the type of this converter, using the specified context and culture information.
|
||||
/// </summary>
|
||||
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
|
||||
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param>
|
||||
/// <param name="value">The <see cref="T:System.Object" /> to convert.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="T:System.Object" /> that represents the converted value.
|
||||
/// </returns>
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
var valueString = value as string;
|
||||
|
||||
if (valueString != null)
|
||||
{
|
||||
return valueString.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(d => double.Parse(d, CultureInfo.InvariantCulture))
|
||||
.AsChartValues();
|
||||
}
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
113
Others/Live-Charts-master/WpfView/DateAxis.cs
Normal file
113
Others/Live-Charts-master/WpfView/DateAxis.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Helpers;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="LiveCharts.Wpf.WindowAxis" />
|
||||
/// <seealso cref="LiveCharts.Definitions.Charts.IDateAxisView" />
|
||||
public class DateAxis : WindowAxis, IDateAxisView
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DateAxis"/> class.
|
||||
/// </summary>
|
||||
public DateAxis()
|
||||
{
|
||||
// Initialize the axis with date windows
|
||||
var collection = new AxisWindowCollection();
|
||||
collection.AddRange(DateAxisWindows.GetDateAxisWindows());
|
||||
SetCurrentValue(WindowsProperty, collection);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The initial date time property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty InitialDateTimeProperty = DependencyProperty.Register(
|
||||
"InitialDateTime", typeof(DateTime), typeof(DateAxis), new PropertyMetadata(DateTime.UtcNow, UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets the Initial Date Time.
|
||||
/// </summary>
|
||||
public DateTime InitialDateTime
|
||||
{
|
||||
get { return (DateTime)GetValue(InitialDateTimeProperty); }
|
||||
set { SetValue(InitialDateTimeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The period property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PeriodProperty = DependencyProperty.Register(
|
||||
"Period", typeof(PeriodUnits), typeof(DateAxis), new PropertyMetadata(PeriodUnits.Milliseconds, UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets the period that represents every unit in the axis.
|
||||
/// </summary>
|
||||
public PeriodUnits Period
|
||||
{
|
||||
get { return (PeriodUnits)GetValue(PeriodProperty); }
|
||||
set { SetValue(PeriodProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Maps as core element.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
public override AxisCore AsCoreElement(ChartCore chart, AxisOrientation source)
|
||||
{
|
||||
if (Model == null) Model = new DateAxisCore(this);
|
||||
Model.ShowLabels = ShowLabels;
|
||||
Model.Chart = chart;
|
||||
Model.IsMerged = IsMerged;
|
||||
Model.Labels = Labels;
|
||||
Model.LabelFormatter = LabelFormatter;
|
||||
Model.MaxValue = MaxValue;
|
||||
Model.MinValue = MinValue;
|
||||
Model.Title = Title;
|
||||
Model.Position = Position;
|
||||
Model.Separator = Separator.AsCoreElement(Model, source);
|
||||
Model.DisableAnimations = DisableAnimations;
|
||||
Model.Sections = Sections.Select(x => x.AsCoreElement(Model, source)).ToList();
|
||||
|
||||
((DateAxisCore)Model).Windows = Windows.ToList();
|
||||
((DateAxisCore)Model).Windows.ForEach(w => ((DateAxisWindow)w).DateAxisCore = (DateAxisCore)Model);
|
||||
return Model;
|
||||
}
|
||||
}
|
||||
}
|
||||
96
Others/Live-Charts-master/WpfView/DefaultAxes.cs
Normal file
96
Others/Live-Charts-master/WpfView/DefaultAxes.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a collection of already defined axes.
|
||||
/// </summary>
|
||||
public static class DefaultAxes
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns default axis
|
||||
/// </summary>
|
||||
public static AxesCollection DefaultAxis
|
||||
{
|
||||
get { return new AxesCollection {new Axis()}; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return an axis without separators at all
|
||||
/// </summary>
|
||||
public static AxesCollection CleanAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
return new AxesCollection
|
||||
{
|
||||
new Axis
|
||||
{
|
||||
IsEnabled = false,
|
||||
Separator = CleanSeparator
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an axis that only displays a line for zero
|
||||
/// </summary>
|
||||
public static AxesCollection OnlyZerosAxis
|
||||
{
|
||||
get
|
||||
{
|
||||
return new AxesCollection
|
||||
{
|
||||
new Axis
|
||||
{
|
||||
IsEnabled = true,
|
||||
Separator = CleanSeparator
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Returns a clean separator
|
||||
/// <summary>
|
||||
/// Gets the clean separator.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The clean separator.
|
||||
/// </value>
|
||||
public static Separator CleanSeparator
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Separator
|
||||
{
|
||||
Visibility = Visibility.Collapsed
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
65
Others/Live-Charts-master/WpfView/DefaultGeoMapTooltip.xaml
Normal file
65
Others/Live-Charts-master/WpfView/DefaultGeoMapTooltip.xaml
Normal file
@@ -0,0 +1,65 @@
|
||||
<!--
|
||||
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
-->
|
||||
|
||||
<UserControl x:Class="LiveCharts.Wpf.DefaultGeoMapTooltip"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300"
|
||||
d:DataContext="{d:DesignInstance lvc:DefaultGeoMapTooltip}"
|
||||
BorderThickness="1.3">
|
||||
<UserControl.Background>
|
||||
<SolidColorBrush Color="#202020" Opacity=".8" />
|
||||
</UserControl.Background>
|
||||
<UserControl.Resources>
|
||||
<lvc:GeoDataLabelConverter x:Key="DataLabelConverter"></lvc:GeoDataLabelConverter>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Template>
|
||||
<ControlTemplate>
|
||||
<Border Background="{Binding Background}" CornerRadius="{Binding CornerRadius}"
|
||||
BorderThickness="{Binding BorderThickness}" Padding="20 10">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontWeight="Bold" Foreground="White" Text="{Binding GeoData.Name}"></TextBlock>
|
||||
<TextBlock Grid.Column="1" Margin="10 0 0 0" Foreground="White" FontWeight="Bold">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource DataLabelConverter}">
|
||||
<Binding Path="GeoData.Value" />
|
||||
<Binding Path="LabelFormatter" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</UserControl.Template>
|
||||
</UserControl>
|
||||
161
Others/Live-Charts-master/WpfView/DefaultGeoMapTooltip.xaml.cs
Normal file
161
Others/Live-Charts-master/WpfView/DefaultGeoMapTooltip.xaml.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
public partial class DefaultGeoMapTooltip : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DefaultGeoMapTooltip"/> class.
|
||||
/// </summary>
|
||||
public DefaultGeoMapTooltip()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
SetCurrentValue(CornerRadiusProperty, 4d);
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The corner radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
|
||||
"CornerRadius", typeof (double), typeof (DefaultGeoMapTooltip), new PropertyMetadata(default(double)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the corner radius.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The corner radius.
|
||||
/// </value>
|
||||
public double CornerRadius
|
||||
{
|
||||
get { return (double) GetValue(CornerRadiusProperty); }
|
||||
set { SetValue(CornerRadiusProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The label formatter property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelFormatterProperty = DependencyProperty.Register(
|
||||
"LabelFormatter", typeof (Func<double, string>), typeof (DefaultGeoMapTooltip), new PropertyMetadata(default(Func<double, string>)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the label formatter.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The label formatter.
|
||||
/// </value>
|
||||
public Func<double, string> LabelFormatter
|
||||
{
|
||||
get { return (Func<double, string>) GetValue(LabelFormatterProperty); }
|
||||
set { SetValue(LabelFormatterProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The geo data property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty GeoDataProperty = DependencyProperty.Register(
|
||||
"GeoData", typeof (GeoData), typeof (DefaultGeoMapTooltip), new PropertyMetadata(default(GeoData)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the geo data.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The geo data.
|
||||
/// </value>
|
||||
public GeoData GeoData
|
||||
{
|
||||
get { return (GeoData) GetValue(GeoDataProperty); }
|
||||
set { SetValue(GeoDataProperty, value); }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class GeoData
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The name.
|
||||
/// </value>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The value.
|
||||
/// </value>
|
||||
public double Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Data.IMultiValueConverter" />
|
||||
public class GeoDataLabelConverter : IMultiValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of values that the source bindings in the <see cref="T:System.Windows.Data.MultiBinding" /> produces. The value <see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the source binding has no value to provide for conversion.</param>
|
||||
/// <param name="targetType">The type of the binding target property.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value.If the method returns null, the valid null value is used.A return value of <see cref="T:System.Windows.DependencyProperty" />.<see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the converter did not produce a value, and that the binding will use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> if it is available, or else will use the default value.A return value of <see cref="T:System.Windows.Data.Binding" />.<see cref="F:System.Windows.Data.Binding.DoNothing" /> indicates that the binding does not transfer the value or use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> or the default value.
|
||||
/// </returns>
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
Func<double, string> defF = x => x.ToString(CultureInfo.InvariantCulture);
|
||||
var f = values[1] as Func<double, string> ?? defF;
|
||||
return f(values[0] as double? ?? 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a binding target value to the source binding values.
|
||||
/// </summary>
|
||||
/// <param name="value">The value that the binding target produces.</param>
|
||||
/// <param name="targetTypes">The array of types to convert to. The array length indicates the number and types of values that are suggested for the method to return.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// An array of values that have been converted from the target value back to the source values.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
105
Others/Live-Charts-master/WpfView/DefaultGeometry.cs
Normal file
105
Others/Live-Charts-master/WpfView/DefaultGeometry.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains an already defined collection of geometries, useful to set the Series.PointGeomety property
|
||||
/// </summary>
|
||||
public static class DefaultGeometries
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a null geometry
|
||||
/// </summary>
|
||||
public static Geometry None
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a circle geometry
|
||||
/// </summary>
|
||||
public static Geometry Circle
|
||||
{
|
||||
get
|
||||
{
|
||||
var g = Geometry.Parse("M 0,0 A 180,180 180 1 1 1,1 Z");
|
||||
g.Freeze();
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a square geometry
|
||||
/// </summary>
|
||||
public static Geometry Square
|
||||
{
|
||||
get
|
||||
{
|
||||
var g = Geometry.Parse("M 1,1 h -2 v -2 h 2 z");
|
||||
g.Freeze();
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a diamond geometry
|
||||
/// </summary>
|
||||
public static Geometry Diamond
|
||||
{
|
||||
get
|
||||
{
|
||||
var g = Geometry.Parse("M 1,0 L 2,1 1,2 0,1 z");
|
||||
g.Freeze();
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a triangle geometry
|
||||
/// </summary>
|
||||
public static Geometry Triangle
|
||||
{
|
||||
get
|
||||
{
|
||||
var g = Geometry.Parse("M 0,1 l 1,1 h -2 Z");
|
||||
g.Freeze();
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a cross geometry
|
||||
/// </summary>
|
||||
public static Geometry Cross
|
||||
{
|
||||
get
|
||||
{
|
||||
var g = Geometry.Parse("M0,0 L1,1 M0,1 l1,-1");
|
||||
g.Freeze();
|
||||
return g;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Others/Live-Charts-master/WpfView/DefaultLegend.xaml
Normal file
76
Others/Live-Charts-master/WpfView/DefaultLegend.xaml
Normal file
@@ -0,0 +1,76 @@
|
||||
<!--
|
||||
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
-->
|
||||
|
||||
<UserControl x:Class="LiveCharts.Wpf.DefaultLegend"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:LiveCharts.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:DefaultLegend}"
|
||||
Name="This">
|
||||
<UserControl.Resources>
|
||||
<local:OrientationConverter x:Key="OrientationConverter"></local:OrientationConverter>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Template>
|
||||
<ControlTemplate>
|
||||
<Border>
|
||||
<ItemsControl ItemsSource="{Binding Series}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel MaxWidth="{Binding MaxWidth, ElementName=This}"
|
||||
MaxHeight="{Binding MaxHeight, ElementName=This}">
|
||||
<WrapPanel.Orientation>
|
||||
<MultiBinding Converter="{StaticResource OrientationConverter}">
|
||||
<Binding Path="Orientation"/>
|
||||
<Binding Path="InternalOrientation"/>
|
||||
</MultiBinding>
|
||||
</WrapPanel.Orientation>
|
||||
</WrapPanel>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type local:SeriesViewModel}">
|
||||
<Grid Margin="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Path Width="{Binding BulletSize, RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type UserControl}}}"
|
||||
Height="{Binding BulletSize, RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type UserControl}}}"
|
||||
StrokeThickness="{Binding StrokeThickness}"
|
||||
Stroke="{Binding Stroke}" Fill="{Binding Fill}"
|
||||
Stretch="Fill" Data="{Binding PointGeometry}"/>
|
||||
<TextBlock Grid.Column="1" Margin="4 0" Text="{Binding Title}" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</UserControl.Template>
|
||||
</UserControl>
|
||||
164
Others/Live-Charts-master/WpfView/DefaultLegend.xaml.cs
Normal file
164
Others/Live-Charts-master/WpfView/DefaultLegend.xaml.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The default legend control, by default a new instance of this control is created for every chart that requires a legend.
|
||||
/// </summary>
|
||||
public partial class DefaultLegend : IChartLegend
|
||||
{
|
||||
private List<SeriesViewModel> _series;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of DefaultLegend class
|
||||
/// </summary>
|
||||
public DefaultLegend()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Property changed event
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the series displayed in the legend.
|
||||
/// </summary>
|
||||
public List<SeriesViewModel> Series
|
||||
{
|
||||
get { return _series; }
|
||||
set
|
||||
{
|
||||
_series = value;
|
||||
OnPropertyChanged("Series");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The orientation property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
|
||||
"Orientation", typeof (Orientation?), typeof (DefaultLegend), new PropertyMetadata(null));
|
||||
/// <summary>
|
||||
/// Gets or sets the orientation of the legend, default is null, if null LiveCharts will decide which orientation to use, based on the Chart.Legend location property.
|
||||
/// </summary>
|
||||
public Orientation? Orientation
|
||||
{
|
||||
get { return (Orientation) GetValue(OrientationProperty); }
|
||||
set { SetValue(OrientationProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The internal orientation property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty InternalOrientationProperty = DependencyProperty.Register(
|
||||
"InternalOrientation", typeof (Orientation), typeof (DefaultLegend),
|
||||
new PropertyMetadata(default(Orientation)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the internal orientation.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The internal orientation.
|
||||
/// </value>
|
||||
public Orientation InternalOrientation
|
||||
{
|
||||
get { return (Orientation) GetValue(InternalOrientationProperty); }
|
||||
set { SetValue(InternalOrientationProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The bullet size property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty BulletSizeProperty = DependencyProperty.Register(
|
||||
"BulletSize", typeof(double), typeof(DefaultLegend), new PropertyMetadata(15d));
|
||||
/// <summary>
|
||||
/// Gets or sets the bullet size, the bullet size modifies the drawn shape size.
|
||||
/// </summary>
|
||||
public double BulletSize
|
||||
{
|
||||
get { return (double)GetValue(BulletSizeProperty); }
|
||||
set { SetValue(BulletSizeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when [property changed].
|
||||
/// </summary>
|
||||
/// <param name="propertyName">Name of the property.</param>
|
||||
protected virtual void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
if (PropertyChanged != null) PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Data.IMultiValueConverter" />
|
||||
public class OrientationConverter : IMultiValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of values that the source bindings in the <see cref="T:System.Windows.Data.MultiBinding" /> produces. The value <see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the source binding has no value to provide for conversion.</param>
|
||||
/// <param name="targetType">The type of the binding target property.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value.If the method returns null, the valid null value is used.A return value of <see cref="T:System.Windows.DependencyProperty" />.<see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the converter did not produce a value, and that the binding will use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> if it is available, or else will use the default value.A return value of <see cref="T:System.Windows.Data.Binding" />.<see cref="F:System.Windows.Data.Binding.DoNothing" /> indicates that the binding does not transfer the value or use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> or the default value.
|
||||
/// </returns>
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values[0] == DependencyProperty.UnsetValue) return null;
|
||||
|
||||
return (Orientation?) values[0] ?? (Orientation) values[1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a binding target value to the source binding values.
|
||||
/// </summary>
|
||||
/// <param name="value">The value that the binding target produces.</param>
|
||||
/// <param name="targetTypes">The array of types to convert to. The array length indicates the number and types of values that are suggested for the method to return.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// An array of values that have been converted from the target value back to the source values.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
99
Others/Live-Charts-master/WpfView/DefaultTooltip.xaml
Normal file
99
Others/Live-Charts-master/WpfView/DefaultTooltip.xaml
Normal file
@@ -0,0 +1,99 @@
|
||||
<!--
|
||||
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
-->
|
||||
|
||||
<UserControl x:Class="LiveCharts.Wpf.DefaultTooltip"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:wpf="clr-namespace:LiveCharts.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance wpf:DefaultTooltip}"
|
||||
x:Name="Control">
|
||||
<UserControl.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{Binding Foreground}"></Setter>
|
||||
</Style>
|
||||
<wpf:SharedConverter x:Key="SharedConverter"/>
|
||||
<wpf:SharedVisibilityConverter x:Key="SharedVisibilityConverter"/>
|
||||
<wpf:ChartPointLabelConverter x:Key="ChartPointLabelConverter"/>
|
||||
<wpf:ParticipationVisibilityConverter x:Key="ParticipationVisibilityConverter"/>
|
||||
<BooleanToVisibilityConverter x:Key="Bvc"></BooleanToVisibilityConverter>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Template>
|
||||
<ControlTemplate>
|
||||
<Grid VerticalAlignment="Center" HorizontalAlignment="Center" >
|
||||
<Border Background="{Binding Background}" BorderThickness="1" Effect="{Binding Effect}" CornerRadius="{Binding CornerRadius}"
|
||||
Width="{Binding Width}" Height="{Binding Height}"/>
|
||||
<Border Background="{Binding Background}" CornerRadius="{Binding CornerRadius}"
|
||||
BorderThickness="{Binding BorderThickness}" Padding="{Binding Padding}"
|
||||
BorderBrush="{Binding BorderBrush}"
|
||||
Width="{Binding Width}" Height="{Binding Height}">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="{Binding Data, Converter={StaticResource SharedConverter}}" HorizontalAlignment="Center" FontWeight="Bold">
|
||||
<TextBlock.Visibility>
|
||||
<MultiBinding Converter="{StaticResource SharedVisibilityConverter}">
|
||||
<Binding Path="Data"></Binding>
|
||||
<Binding Path="ShowTitle"></Binding>
|
||||
</MultiBinding>
|
||||
</TextBlock.Visibility>
|
||||
</TextBlock>
|
||||
<ItemsControl ItemsSource="{Binding Data.Points}" Grid.IsSharedSizeScope="True">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type wpf:DataPointViewModel}">
|
||||
<Grid Margin="2" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Title"/>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Label"/>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Participation"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Path Width="{Binding BulletSize, RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type UserControl}}}"
|
||||
Height="{Binding BulletSize, RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type UserControl}}}"
|
||||
StrokeThickness="{Binding Series.StrokeThickness}"
|
||||
Stroke="{Binding Series.Stroke}" Fill="{Binding Series.Fill}"
|
||||
Stretch="Fill" Data="{Binding Series.PointGeometry}"
|
||||
Visibility="{Binding ShowSeries, ElementName=Control, Converter={StaticResource Bvc}}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Series.Title}" VerticalAlignment="Center" Margin="5 0 5 0"
|
||||
Visibility="{Binding ShowSeries, ElementName=Control, Converter={StaticResource Bvc}}"/>
|
||||
|
||||
<TextBlock Grid.Column="2" Text="{Binding ChartPoint, Converter={StaticResource ChartPointLabelConverter}}" VerticalAlignment="Center"/>
|
||||
|
||||
<TextBlock Grid.Column="3" Text="{Binding ChartPoint.Participation, StringFormat={}{0:P}}"
|
||||
VerticalAlignment="Center" Margin="5 0 0 0"
|
||||
Visibility="{Binding DataContext.Data, RelativeSource={RelativeSource FindAncestor,
|
||||
AncestorType={x:Type StackPanel}},
|
||||
Converter={StaticResource ParticipationVisibilityConverter}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</UserControl.Template>
|
||||
</UserControl>
|
||||
439
Others/Live-Charts-master/WpfView/DefaultTooltip.xaml.cs
Normal file
439
Others/Live-Charts-master/WpfView/DefaultTooltip.xaml.cs
Normal file
@@ -0,0 +1,439 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The Default Tooltip control, by default any chart that requires a tooltip will create a new instance of this class.
|
||||
/// </summary>
|
||||
public partial class DefaultTooltip : IChartTooltip
|
||||
{
|
||||
private TooltipData _data;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of DefaultTooltip class
|
||||
/// </summary>
|
||||
public DefaultTooltip()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="DefaultTooltip"/> class.
|
||||
/// </summary>
|
||||
static DefaultTooltip()
|
||||
{
|
||||
BackgroundProperty.OverrideMetadata(
|
||||
typeof(DefaultTooltip), new FrameworkPropertyMetadata(new SolidColorBrush(Color.FromArgb(140, 255, 255, 255))));
|
||||
PaddingProperty.OverrideMetadata(
|
||||
typeof(DefaultTooltip), new FrameworkPropertyMetadata(new Thickness(10, 5, 10, 5)));
|
||||
EffectProperty.OverrideMetadata(
|
||||
typeof(DefaultTooltip),
|
||||
new FrameworkPropertyMetadata(new DropShadowEffect {BlurRadius = 3, Color = Color.FromRgb(50,50,50), Opacity = .2}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The show title property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShowTitleProperty = DependencyProperty.Register(
|
||||
"ShowTitle", typeof(bool), typeof(DefaultTooltip), new PropertyMetadata(true));
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the tooltip should show the shared coordinate value in the current tooltip data.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [show title]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool ShowTitle
|
||||
{
|
||||
get { return (bool) GetValue(ShowTitleProperty); }
|
||||
set { SetValue(ShowTitleProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The show series property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShowSeriesProperty = DependencyProperty.Register(
|
||||
"ShowSeries", typeof(bool), typeof(DefaultTooltip), new PropertyMetadata(true));
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether should show series name and color.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [show series]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool ShowSeries
|
||||
{
|
||||
get { return (bool) GetValue(ShowSeriesProperty); }
|
||||
set { SetValue(ShowSeriesProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The corner radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
|
||||
"CornerRadius", typeof (CornerRadius), typeof (DefaultTooltip), new PropertyMetadata(new CornerRadius(4)));
|
||||
/// <summary>
|
||||
/// Gets or sets the corner radius of the tooltip
|
||||
/// </summary>
|
||||
public CornerRadius CornerRadius
|
||||
{
|
||||
get { return (CornerRadius) GetValue(CornerRadiusProperty); }
|
||||
set { SetValue(CornerRadiusProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The selection mode property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SelectionModeProperty = DependencyProperty.Register(
|
||||
"SelectionMode", typeof (TooltipSelectionMode?), typeof (DefaultTooltip),
|
||||
new PropertyMetadata(null));
|
||||
/// <summary>
|
||||
/// Gets or sets the tooltip selection mode, default is null, if this property is null LiveCharts will decide the selection mode based on the series (that fired the tooltip) preferred section mode
|
||||
/// </summary>
|
||||
public TooltipSelectionMode? SelectionMode
|
||||
{
|
||||
get { return (TooltipSelectionMode?) GetValue(SelectionModeProperty); }
|
||||
set { SetValue(SelectionModeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The bullet size property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty BulletSizeProperty = DependencyProperty.Register(
|
||||
"BulletSize", typeof (double), typeof (DefaultTooltip), new PropertyMetadata(15d));
|
||||
/// <summary>
|
||||
/// Gets or sets the bullet size, the bullet size modifies the drawn shape size.
|
||||
/// </summary>
|
||||
public double BulletSize
|
||||
{
|
||||
get { return (double) GetValue(BulletSizeProperty); }
|
||||
set { SetValue(BulletSizeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The is wrapped property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsWrappedProperty = DependencyProperty.Register(
|
||||
"IsWrapped", typeof (bool), typeof (DefaultTooltip), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets whether the tooltip is shared in the current view, this property is useful to control
|
||||
/// the z index of a tooltip according to a set of controls in a container.
|
||||
/// </summary>
|
||||
public bool IsWrapped
|
||||
{
|
||||
get { return (bool) GetValue(IsWrappedProperty); }
|
||||
set { SetValue(IsWrappedProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the data.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The data.
|
||||
/// </value>
|
||||
public TooltipData Data
|
||||
{
|
||||
get { return _data; }
|
||||
set
|
||||
{
|
||||
_data = value;
|
||||
OnPropertyChanged("Data");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [property changed].
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Called when [property changed].
|
||||
/// </summary>
|
||||
/// <param name="propertyName">Name of the property.</param>
|
||||
protected virtual void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Data.IValueConverter" />
|
||||
public class SharedConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value produced by the binding source.</param>
|
||||
/// <param name="targetType">The type of the binding target property.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns null, the valid null value is used.
|
||||
/// </returns>
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var v = value as TooltipData;
|
||||
|
||||
if (v == null) return null;
|
||||
|
||||
if (v.SelectionMode == TooltipSelectionMode.OnlySender) return string.Empty;
|
||||
|
||||
return v.SelectionMode == TooltipSelectionMode.SharedXValues
|
||||
? v.XFormatter(v.SharedValue ?? 0)
|
||||
: v.YFormatter(v.SharedValue ?? 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value that is produced by the binding target.</param>
|
||||
/// <param name="targetType">The type to convert to.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns null, the valid null value is used.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Data.IValueConverter" />
|
||||
public class ChartPointLabelConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value produced by the binding source.</param>
|
||||
/// <param name="targetType">The type of the binding target property.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns null, the valid null value is used.
|
||||
/// </returns>
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var chartPoint = value as ChartPoint;
|
||||
|
||||
if (chartPoint == null) return null;
|
||||
|
||||
return chartPoint.SeriesView.LabelPoint(chartPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value that is produced by the binding target.</param>
|
||||
/// <param name="targetType">The type to convert to.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns null, the valid null value is used.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Data.IValueConverter" />
|
||||
public class ParticipationVisibilityConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value produced by the binding source.</param>
|
||||
/// <param name="targetType">The type of the binding target property.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns null, the valid null value is used.
|
||||
/// </returns>
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var v = value as TooltipData;
|
||||
if (v == null) return null;
|
||||
|
||||
return v.Points.Any(x => x.ChartPoint.Participation > 0) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value that is produced by the binding target.</param>
|
||||
/// <param name="targetType">The type to convert to.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value. If the method returns null, the valid null value is used.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Data.IMultiValueConverter" />
|
||||
public class SharedVisibilityConverter : IMultiValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of values that the source bindings in the <see cref="T:System.Windows.Data.MultiBinding" /> produces. The value <see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the source binding has no value to provide for conversion.</param>
|
||||
/// <param name="targetType">The type of the binding target property.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value.If the method returns null, the valid null value is used.A return value of <see cref="T:System.Windows.DependencyProperty" />.<see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the converter did not produce a value, and that the binding will use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> if it is available, or else will use the default value.A return value of <see cref="T:System.Windows.Data.Binding" />.<see cref="F:System.Windows.Data.Binding.DoNothing" /> indicates that the binding does not transfer the value or use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> or the default value.
|
||||
/// </returns>
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var v = values[0] as TooltipData;
|
||||
var show = values[1] as bool?;
|
||||
|
||||
if (v == null || show == null) return null;
|
||||
|
||||
if (show.Value == false)
|
||||
return Visibility.Collapsed;
|
||||
|
||||
if (v.SelectionMode == TooltipSelectionMode.OnlySender)
|
||||
return Visibility.Collapsed;
|
||||
|
||||
return v.SharedValue == null
|
||||
? Visibility.Collapsed
|
||||
: Visibility.Visible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a binding target value to the source binding values.
|
||||
/// </summary>
|
||||
/// <param name="value">The value that the binding target produces.</param>
|
||||
/// <param name="targetTypes">The array of types to convert to. The array length indicates the number and types of values that are suggested for the method to return.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// An array of values that have been converted from the target value back to the source values.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains information about data in a tooltip
|
||||
/// </summary>
|
||||
public class TooltipData
|
||||
{
|
||||
/// <summary>
|
||||
/// The current X formatter
|
||||
/// </summary>
|
||||
public Func<double, string> XFormatter { get; set; }
|
||||
/// <summary>
|
||||
/// The current Y formatter
|
||||
/// </summary>
|
||||
public Func<double, string> YFormatter { get; set; }
|
||||
/// <summary>
|
||||
/// Shared coordinate value between points
|
||||
/// </summary>
|
||||
public double? SharedValue { get; set; }
|
||||
/// <summary>
|
||||
/// Current selection mode
|
||||
/// </summary>
|
||||
public TooltipSelectionMode SelectionMode { get; set; }
|
||||
/// <summary>
|
||||
/// collection of points
|
||||
/// </summary>
|
||||
public List<DataPointViewModel> Points { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Point Data
|
||||
/// </summary>
|
||||
public class DataPointViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets info about the series that owns the point, like stroke and stroke thickness
|
||||
/// </summary>
|
||||
public SeriesViewModel Series { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the ChartPoint instance
|
||||
/// </summary>
|
||||
public ChartPoint ChartPoint { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Series Data
|
||||
/// </summary>
|
||||
public class SeriesViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Series Title
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// Series stroke
|
||||
/// </summary>
|
||||
public Brush Stroke { get; set; }
|
||||
/// <summary>
|
||||
/// Series Stroke thickness
|
||||
/// </summary>
|
||||
public double StrokeThickness { get; set; }
|
||||
/// <summary>
|
||||
/// Series Fill
|
||||
/// </summary>
|
||||
public Brush Fill { get; set; }
|
||||
/// <summary>
|
||||
/// Series point Geometry
|
||||
/// </summary>
|
||||
public Geometry PointGeometry { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp50</s:String></wpf:ResourceDictionary>
|
||||
85
Others/Live-Charts-master/WpfView/Extentions.cs
Normal file
85
Others/Live-Charts-master/WpfView/Extentions.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class Extentions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a point at screen to chart values scale
|
||||
/// </summary>
|
||||
/// <param name="chart">Target chart</param>
|
||||
/// <param name="screenPoint">point in screen</param>
|
||||
/// <param name="axisX">axis x index</param>
|
||||
/// <param name="axisY">axis y index</param>
|
||||
/// <returns></returns>
|
||||
public static Point ConvertToChartValues(this Chart chart, Point screenPoint, int axisX = 0, int axisY = 0)
|
||||
{
|
||||
if (chart.Model == null || chart.AxisX == null || chart.AxisX.Any(x => x.Model == null)) return new Point();
|
||||
|
||||
var uw = new CorePoint(
|
||||
chart.AxisX[axisX].Model.EvaluatesUnitWidth
|
||||
? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart.Model, axisX) / 2
|
||||
: 0,
|
||||
chart.AxisY[axisY].Model.EvaluatesUnitWidth
|
||||
? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart.Model, axisY) / 2
|
||||
: 0);
|
||||
|
||||
return new Point(
|
||||
ChartFunctions.FromPlotArea(screenPoint.X - uw.X, AxisOrientation.X, chart.Model, axisX),
|
||||
ChartFunctions.FromPlotArea(screenPoint.Y - uw.Y, AxisOrientation.Y, chart.Model, axisY));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a chart values pair to pixels
|
||||
/// </summary>
|
||||
/// <param name="chart">Target chart</param>
|
||||
/// <param name="chartPoint">point in screen</param>
|
||||
/// <param name="axisX">axis x index</param>
|
||||
/// <param name="axisY">axis y index</param>
|
||||
/// <returns></returns>
|
||||
public static Point ConvertToPixels(this Chart chart, Point chartPoint, int axisX = 0, int axisY = 0)
|
||||
{
|
||||
if (chart.Model == null || chart.AxisX.Any(x => x.Model == null)) return new Point();
|
||||
|
||||
var uw = new CorePoint(
|
||||
chart.AxisX[axisX].Model.EvaluatesUnitWidth
|
||||
? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart.Model, axisX) / 2
|
||||
: 0,
|
||||
chart.AxisY[axisY].Model.EvaluatesUnitWidth
|
||||
? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart.Model, axisY) / 2
|
||||
: 0);
|
||||
|
||||
return new Point(
|
||||
ChartFunctions.ToPlotArea(chartPoint.X, AxisOrientation.X, chart.Model, axisX) + uw.X,
|
||||
ChartFunctions.ToPlotArea(chartPoint.Y, AxisOrientation.Y, chart.Model, axisY) + uw.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a ChartPoint to Point
|
||||
/// </summary>
|
||||
/// <param name="chartPoint">point to convert</param>
|
||||
/// <returns></returns>
|
||||
public static Point AsPoint(this ChartPoint chartPoint)
|
||||
{
|
||||
return new Point(chartPoint.X, chartPoint.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a CorePoint to Point
|
||||
/// </summary>
|
||||
/// <param name="point">point to convert</param>
|
||||
/// <returns></returns>
|
||||
internal static Point AsPoint(this CorePoint point)
|
||||
{
|
||||
return new Point(point.X, point.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
Others/Live-Charts-master/WpfView/FinancialColoringRule.cs
Normal file
55
Others/Live-Charts-master/WpfView/FinancialColoringRule.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a condition that decides the fill and stroke to use in a CandleStick series
|
||||
/// </summary>
|
||||
public class FinancialColoringRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FinancialColoringRule"/> class.
|
||||
/// </summary>
|
||||
public FinancialColoringRule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FinancialColoringRule"/> class.
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition.</param>
|
||||
/// <param name="stroke">The stroke.</param>
|
||||
/// <param name="fill">The fill.</param>
|
||||
public FinancialColoringRule(FinancialDelegate condition, Brush stroke, Brush fill)
|
||||
{
|
||||
Condition = condition;
|
||||
Stroke = stroke;
|
||||
Fill = fill;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the condition, if the condition returns true, the point will use the defined Stroke/Fill properties in the FinancialColoringRule object
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The condition.
|
||||
/// </value>
|
||||
public FinancialDelegate Condition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the stroke to use when the condition returns true.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The stroke.
|
||||
/// </value>
|
||||
public Brush Stroke { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fill to use when the condition returns true.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The fill.
|
||||
/// </value>
|
||||
public Brush Fill { get; set; }
|
||||
}
|
||||
}
|
||||
519
Others/Live-Charts-master/WpfView/Gauge.cs
Normal file
519
Others/Live-Charts-master/WpfView/Gauge.cs
Normal file
@@ -0,0 +1,519 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Wpf.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The gauge chart is useful to display progress or completion.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Controls.UserControl" />
|
||||
public class Gauge : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Gauge"/> class.
|
||||
/// </summary>
|
||||
public Gauge()
|
||||
{
|
||||
Canvas = new Canvas();
|
||||
Content = Canvas;
|
||||
|
||||
PieBack = new PieSlice();
|
||||
Pie = new PieSlice();
|
||||
MeasureTextBlock = new TextBlock();
|
||||
LeftLabel = new TextBlock();
|
||||
RightLabel = new TextBlock();
|
||||
|
||||
Canvas.Children.Add(PieBack);
|
||||
Canvas.Children.Add(Pie);
|
||||
Canvas.Children.Add(MeasureTextBlock);
|
||||
Canvas.Children.Add(RightLabel);
|
||||
Canvas.Children.Add(LeftLabel);
|
||||
|
||||
Panel.SetZIndex(MeasureTextBlock, 1);
|
||||
Panel.SetZIndex(RightLabel, 1);
|
||||
Panel.SetZIndex(LeftLabel, 1);
|
||||
|
||||
Panel.SetZIndex(PieBack, 0);
|
||||
Panel.SetZIndex(Pie, 1);
|
||||
|
||||
Canvas.SetBinding(WidthProperty,
|
||||
new Binding { Path = new PropertyPath(WidthProperty), Source = this });
|
||||
Canvas.SetBinding(HeightProperty,
|
||||
new Binding { Path = new PropertyPath(HeightProperty), Source = this });
|
||||
|
||||
PieBack.SetBinding(Shape.FillProperty,
|
||||
new Binding { Path = new PropertyPath(GaugeBackgroundProperty), Source = this });
|
||||
PieBack.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding { Path = new PropertyPath(StrokeThicknessProperty), Source = this });
|
||||
PieBack.SetBinding(Shape.StrokeProperty,
|
||||
new Binding { Path = new PropertyPath(StrokeProperty), Source = this });
|
||||
PieBack.SetBinding(RenderTransformProperty,
|
||||
new Binding {Path = new PropertyPath(GaugeRenderTransformProperty), Source = this});
|
||||
|
||||
Pie.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding { Path = new PropertyPath(StrokeThicknessProperty), Source = this });
|
||||
Pie.SetBinding(RenderTransformProperty,
|
||||
new Binding { Path = new PropertyPath(GaugeRenderTransformProperty), Source = this });
|
||||
Pie.Stroke = Brushes.Transparent;
|
||||
|
||||
SetCurrentValue(GaugeBackgroundProperty, new SolidColorBrush(Color.FromRgb(21, 101, 191)) { Opacity = .1 });
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
SetCurrentValue(StrokeProperty, new SolidColorBrush(Color.FromRgb(222, 222, 222)));
|
||||
|
||||
SetCurrentValue(FromColorProperty, Color.FromRgb(100, 180, 245));
|
||||
SetCurrentValue(ToColorProperty, Color.FromRgb(21, 101, 191));
|
||||
|
||||
SetCurrentValue(MinHeightProperty, 20d);
|
||||
SetCurrentValue(MinWidthProperty, 20d);
|
||||
|
||||
SetCurrentValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(800));
|
||||
|
||||
MeasureTextBlock.FontWeight = FontWeights.Bold;
|
||||
|
||||
IsNew = true;
|
||||
|
||||
SizeChanged += (sender, args) =>
|
||||
{
|
||||
IsChartInitialized = true;
|
||||
Update();
|
||||
};
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
private Canvas Canvas { get; set; }
|
||||
private PieSlice PieBack { get; set; }
|
||||
private PieSlice Pie { get; set; }
|
||||
private TextBlock MeasureTextBlock { get; set; }
|
||||
private TextBlock LeftLabel { get; set; }
|
||||
private TextBlock RightLabel { get; set; }
|
||||
private bool IsNew { get; set; }
|
||||
private bool IsChartInitialized { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The gauge active fill property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty GaugeActiveFillProperty = DependencyProperty.Register(
|
||||
"GaugeActiveFill", typeof(Brush), typeof(Gauge), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the gauge active fill, if this property is set, From/to color properties interpolation will be ignored
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The gauge active fill.
|
||||
/// </value>
|
||||
public Brush GaugeActiveFill
|
||||
{
|
||||
get { return (Brush) GetValue(GaugeActiveFillProperty); }
|
||||
set { SetValue(GaugeActiveFillProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The labels visibility property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelsVisibilityProperty = DependencyProperty.Register(
|
||||
"LabelsVisibility", typeof(Visibility), typeof(Gauge), new PropertyMetadata(default(Visibility)));
|
||||
/// <summary>
|
||||
/// Gets or sets the labels visibility.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The labels visibility.
|
||||
/// </value>
|
||||
public Visibility LabelsVisibility
|
||||
{
|
||||
get { return (Visibility) GetValue(LabelsVisibilityProperty); }
|
||||
set { SetValue(LabelsVisibilityProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The gauge render transform property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty GaugeRenderTransformProperty = DependencyProperty.Register(
|
||||
"GaugeRenderTransform", typeof(Transform), typeof(Gauge), new PropertyMetadata(default(Transform)));
|
||||
/// <summary>
|
||||
/// Gets or sets the gauge render transform.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The gauge render transform.
|
||||
/// </value>
|
||||
public Transform GaugeRenderTransform
|
||||
{
|
||||
get { return (Transform) GetValue(GaugeRenderTransformProperty); }
|
||||
set { SetValue(GaugeRenderTransformProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The uses360 mode property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty Uses360ModeProperty = DependencyProperty.Register(
|
||||
"Uses360Mode", typeof(bool), typeof(Gauge), new PropertyMetadata(default(bool), UpdateCallback));
|
||||
/// <summary>
|
||||
/// Gets or sets whether the gauge uses 360 mode, 360 mode will plot a full circle instead of a semi circle
|
||||
/// </summary>
|
||||
public bool Uses360Mode
|
||||
{
|
||||
get { return (bool)GetValue(Uses360ModeProperty); }
|
||||
set { SetValue(Uses360ModeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FromProperty = DependencyProperty.Register(
|
||||
"From", typeof(double), typeof(Gauge), new PropertyMetadata(0d, UpdateCallback));
|
||||
/// <summary>
|
||||
/// Gets or sets the value where the gauge starts
|
||||
/// </summary>
|
||||
public double From
|
||||
{
|
||||
get { return (double)GetValue(FromProperty); }
|
||||
set { SetValue(FromProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ToProperty = DependencyProperty.Register(
|
||||
"To", typeof(double), typeof(Gauge), new PropertyMetadata(1d, UpdateCallback));
|
||||
/// <summary>
|
||||
/// Gets or sets the value where the gauge ends
|
||||
/// </summary>
|
||||
public double To
|
||||
{
|
||||
get { return (double)GetValue(ToProperty); }
|
||||
set { SetValue(ToProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
|
||||
"Value", typeof(double), typeof(Gauge), new PropertyMetadata(default(double), UpdateCallback));
|
||||
/// <summary>
|
||||
/// Gets or sets the current value of the gauge
|
||||
/// </summary>
|
||||
public double Value
|
||||
{
|
||||
get { return (double)GetValue(ValueProperty); }
|
||||
set { SetValue(ValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The inner radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty InnerRadiusProperty = DependencyProperty.Register(
|
||||
"InnerRadius", typeof(double?), typeof(Gauge), new PropertyMetadata(null, UpdateCallback));
|
||||
/// <summary>
|
||||
/// Gets o sets inner radius
|
||||
/// </summary>
|
||||
public double? InnerRadius
|
||||
{
|
||||
get { return (double?)GetValue(InnerRadiusProperty); }
|
||||
set { SetValue(InnerRadiusProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stroke property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register(
|
||||
"Stroke", typeof(Brush), typeof(Gauge), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets stroke, the stroke is the brush used to draw the gauge border.
|
||||
/// </summary>
|
||||
public Brush Stroke
|
||||
{
|
||||
get { return (Brush)GetValue(StrokeProperty); }
|
||||
set { SetValue(StrokeProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The stroke thickness property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register(
|
||||
"StrokeThickness", typeof(double), typeof(Gauge), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets stroke brush thickness
|
||||
/// </summary>
|
||||
public double StrokeThickness
|
||||
{
|
||||
get { return (double)GetValue(StrokeThicknessProperty); }
|
||||
set { SetValue(StrokeThicknessProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To color property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ToColorProperty = DependencyProperty.Register(
|
||||
"ToColor", typeof(Color), typeof(Gauge), new PropertyMetadata(default(Color), UpdateCallback));
|
||||
/// <summary>
|
||||
/// Gets or sets the color when the current value equals to min value, any value between min and max will use an interpolated color.
|
||||
/// </summary>
|
||||
public Color ToColor
|
||||
{
|
||||
get { return (Color)GetValue(ToColorProperty); }
|
||||
set { SetValue(ToColorProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From color property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FromColorProperty = DependencyProperty.Register(
|
||||
"FromColor", typeof(Color), typeof(Gauge), new PropertyMetadata(default(Color), UpdateCallback));
|
||||
/// <summary>
|
||||
/// Gets or sets the color when the current value equals to max value, any value between min and max will use an interpolated color.
|
||||
/// </summary>
|
||||
public Color FromColor
|
||||
{
|
||||
get { return (Color)GetValue(FromColorProperty); }
|
||||
set { SetValue(FromColorProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The gauge background property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty GaugeBackgroundProperty = DependencyProperty.Register(
|
||||
"GaugeBackground", typeof(Brush), typeof(Gauge), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the gauge background
|
||||
/// </summary>
|
||||
public Brush GaugeBackground
|
||||
{
|
||||
get { return (Brush)GetValue(GaugeBackgroundProperty); }
|
||||
set { SetValue(GaugeBackgroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The animations speed property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty AnimationsSpeedProperty = DependencyProperty.Register(
|
||||
"AnimationsSpeed", typeof(TimeSpan), typeof(Gauge), new PropertyMetadata(default(TimeSpan)));
|
||||
/// <summary>
|
||||
/// G3ts or sets the gauge animations speed
|
||||
/// </summary>
|
||||
public TimeSpan AnimationsSpeed
|
||||
{
|
||||
get { return (TimeSpan)GetValue(AnimationsSpeedProperty); }
|
||||
set { SetValue(AnimationsSpeedProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The disablea animations property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DisableAnimationsProperty = DependencyProperty.Register(
|
||||
"DisableAnimations", typeof(bool), typeof(Gauge), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets whether the chart is animated
|
||||
/// </summary>
|
||||
public bool DisableAnimations
|
||||
{
|
||||
get { return (bool)GetValue(DisableAnimationsProperty); }
|
||||
set { SetValue(DisableAnimationsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The label formatter property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelFormatterProperty = DependencyProperty.Register(
|
||||
"LabelFormatter", typeof(Func<double, string>), typeof(Gauge), new PropertyMetadata(default(Func<double, string>)));
|
||||
/// <summary>
|
||||
/// Gets or sets the label formatter, a label formatter takes a double value, and return a string, e.g. val => val.ToString("C");
|
||||
/// </summary>
|
||||
public Func<double, string> LabelFormatter
|
||||
{
|
||||
get { return (Func<double, string>)GetValue(LabelFormatterProperty); }
|
||||
set { SetValue(LabelFormatterProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The high font size property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HighFontSizeProperty = DependencyProperty.Register(
|
||||
"HighFontSize", typeof(double?), typeof(Gauge), new PropertyMetadata(null));
|
||||
/// <summary>
|
||||
/// Gets o sets the label size, if this value is null then it will be automatically calculated, default is null.
|
||||
/// </summary>
|
||||
public double? HighFontSize
|
||||
{
|
||||
get { return (double?)GetValue(HighFontSizeProperty); }
|
||||
set { SetValue(HighFontSizeProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static void UpdateCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
var gauge = (Gauge)dependencyObject;
|
||||
|
||||
gauge.Update();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!IsChartInitialized) return;
|
||||
|
||||
Func<double, string> defFormatter = x => x.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
var completed = (Value - From) / (To - From);
|
||||
|
||||
var t = 0d;
|
||||
|
||||
if (double.IsNaN(completed) || double.IsInfinity(completed))
|
||||
{
|
||||
completed = 0;
|
||||
}
|
||||
|
||||
completed = completed > 1 ? 1 : (completed < 0 ? 0 : completed);
|
||||
var angle = Uses360Mode ? 360 : 180;
|
||||
|
||||
if (!Uses360Mode)
|
||||
{
|
||||
LeftLabel.Text = (LabelFormatter ?? defFormatter)(From);
|
||||
RightLabel.Text = (LabelFormatter ?? defFormatter)(To);
|
||||
|
||||
LeftLabel.UpdateLayout();
|
||||
RightLabel.UpdateLayout();
|
||||
|
||||
LeftLabel.Visibility = LabelsVisibility;
|
||||
RightLabel.Visibility = LabelsVisibility;
|
||||
|
||||
t = LeftLabel.ActualHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
LeftLabel.Visibility = Visibility.Hidden;
|
||||
RightLabel.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
double r, top;
|
||||
|
||||
if (Uses360Mode)
|
||||
{
|
||||
r = ActualWidth > ActualHeight ? ActualHeight : ActualWidth;
|
||||
r = r / 2 - 2 * t;
|
||||
top = ActualHeight / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = ActualWidth;
|
||||
|
||||
if (ActualWidth > ActualHeight*2)
|
||||
{
|
||||
r = ActualHeight*2;
|
||||
}
|
||||
else
|
||||
{
|
||||
t = 0;
|
||||
}
|
||||
|
||||
r = r / 2 - 2 * t;
|
||||
|
||||
top = ActualHeight / 2 + r / 2;
|
||||
}
|
||||
|
||||
if (r < 0) r = 1;
|
||||
|
||||
PieBack.Radius = r;
|
||||
PieBack.InnerRadius = InnerRadius ?? r * .6;
|
||||
PieBack.RotationAngle = 270;
|
||||
PieBack.WedgeAngle = angle;
|
||||
|
||||
Pie.Radius = PieBack.Radius;
|
||||
Pie.InnerRadius = PieBack.InnerRadius;
|
||||
Pie.RotationAngle = PieBack.RotationAngle;
|
||||
|
||||
Canvas.SetLeft(PieBack, ActualWidth / 2);
|
||||
Canvas.SetTop(PieBack, top);
|
||||
Canvas.SetLeft(Pie, ActualWidth / 2);
|
||||
Canvas.SetTop(Pie, top);
|
||||
|
||||
Canvas.SetTop(LeftLabel, top);
|
||||
Canvas.SetTop(RightLabel, top);
|
||||
Canvas.SetRight(LeftLabel, ActualWidth / 2 + (r + PieBack.InnerRadius) / 2 - LeftLabel.ActualWidth / 2);
|
||||
Canvas.SetRight(RightLabel, ActualWidth / 2 - (r + PieBack.InnerRadius) / 2 - RightLabel.ActualWidth / 2);
|
||||
|
||||
MeasureTextBlock.FontSize = HighFontSize ?? Pie.InnerRadius*.4;
|
||||
MeasureTextBlock.Text = (LabelFormatter ?? defFormatter)(Value);
|
||||
MeasureTextBlock.UpdateLayout();
|
||||
Canvas.SetTop(MeasureTextBlock, top - MeasureTextBlock.ActualHeight * (Uses360Mode ? .5 : 1));
|
||||
Canvas.SetLeft(MeasureTextBlock, ActualWidth / 2 - MeasureTextBlock.ActualWidth / 2);
|
||||
|
||||
var interpolatedColor = new Color
|
||||
{
|
||||
R = LinearInterpolation(FromColor.R, ToColor.R),
|
||||
G = LinearInterpolation(FromColor.G, ToColor.G),
|
||||
B = LinearInterpolation(FromColor.B, ToColor.B),
|
||||
A = LinearInterpolation(FromColor.A, ToColor.A)
|
||||
};
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
Pie.Fill = new SolidColorBrush(FromColor);
|
||||
Pie.WedgeAngle = 0;
|
||||
}
|
||||
|
||||
if (DisableAnimations)
|
||||
{
|
||||
Pie.WedgeAngle = completed * angle;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pie.BeginAnimation(PieSlice.WedgeAngleProperty, new DoubleAnimation(completed * angle, AnimationsSpeed));
|
||||
}
|
||||
|
||||
if (GaugeActiveFill == null)
|
||||
{
|
||||
((SolidColorBrush) Pie.Fill).BeginAnimation(SolidColorBrush.ColorProperty,
|
||||
new ColorAnimation(interpolatedColor, AnimationsSpeed));
|
||||
}
|
||||
else
|
||||
{
|
||||
Pie.Fill = GaugeActiveFill;
|
||||
}
|
||||
|
||||
IsNew = false;
|
||||
}
|
||||
|
||||
private byte LinearInterpolation(double from, double to)
|
||||
{
|
||||
var p1 = new Point(From, from);
|
||||
var p2 = new Point(To, to);
|
||||
|
||||
var deltaX = p2.X - p1.X;
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
||||
var m = (p2.Y - p1.Y) / (deltaX == 0 ? double.MinValue : deltaX);
|
||||
|
||||
var v = Value > To ? To : (Value < From ? From : Value);
|
||||
|
||||
return (byte)(m * (v - p1.X) + p1.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
657
Others/Live-Charts-master/WpfView/GeoMap.cs
Normal file
657
Others/Live-Charts-master/WpfView/GeoMap.cs
Normal file
@@ -0,0 +1,657 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Effects;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Maps;
|
||||
using LiveCharts.Wpf.Maps;
|
||||
using Path = System.Windows.Shapes.Path;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Controls.UserControl" />
|
||||
public class GeoMap : UserControl
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GeoMap"/> class.
|
||||
/// </summary>
|
||||
public GeoMap()
|
||||
{
|
||||
Canvas = new Canvas();
|
||||
Map = new Canvas();
|
||||
Canvas.Children.Add(Map);
|
||||
Content = Canvas;
|
||||
|
||||
Canvas.SetBinding(WidthProperty,
|
||||
new Binding { Path = new PropertyPath(ActualWidthProperty), Source = this });
|
||||
Canvas.SetBinding(HeightProperty,
|
||||
new Binding { Path = new PropertyPath(ActualHeightProperty), Source = this });
|
||||
|
||||
Lands = new Dictionary<string, MapData>();
|
||||
|
||||
SetCurrentValue(DefaultLandFillProperty, new SolidColorBrush(Color.FromArgb(200,255,255,255)));
|
||||
SetCurrentValue(LandStrokeProperty, new SolidColorBrush(Color.FromArgb(30, 55,55, 55)));
|
||||
SetCurrentValue(LandStrokeThicknessProperty, 1.3d);
|
||||
SetCurrentValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(500));
|
||||
SetCurrentValue(BackgroundProperty, new SolidColorBrush(Color.FromArgb(150, 96, 125, 138)));
|
||||
SetCurrentValue(GradientStopCollectionProperty, new GradientStopCollection
|
||||
{
|
||||
new GradientStop(Color.FromArgb(100,2,119,188), 0d),
|
||||
new GradientStop(Color.FromRgb(2,119,188), 1d),
|
||||
});
|
||||
SetCurrentValue(HeatMapProperty, new Dictionary<string, double>());
|
||||
SetCurrentValue(GeoMapTooltipProperty, new DefaultGeoMapTooltip {Visibility = Visibility.Hidden});
|
||||
Canvas.Children.Add(GeoMapTooltip);
|
||||
|
||||
SizeChanged += (sender, e) =>
|
||||
{
|
||||
Draw();
|
||||
};
|
||||
|
||||
MouseWheel += (sender, e) =>
|
||||
{
|
||||
if (!EnableZoomingAndPanning) return;
|
||||
|
||||
e.Handled = true;
|
||||
var rt = Map.RenderTransform as ScaleTransform;
|
||||
var p = rt == null ? 1 : rt.ScaleX;
|
||||
p += e.Delta > 0 ? .05 : -.05;
|
||||
p = p < 1 ? 1 : p;
|
||||
var o = e.GetPosition(this);
|
||||
if (e.Delta > 0) Map.RenderTransformOrigin = new Point(o.X/ActualWidth,o.Y/ActualHeight);
|
||||
Map.RenderTransform = new ScaleTransform(p, p);
|
||||
};
|
||||
|
||||
MouseDown += (sender, e) =>
|
||||
{
|
||||
if (!EnableZoomingAndPanning) return;
|
||||
|
||||
DragOrigin = e.GetPosition(this);
|
||||
};
|
||||
|
||||
MouseUp += (sender, e) =>
|
||||
{
|
||||
if (!EnableZoomingAndPanning) return;
|
||||
|
||||
var end = e.GetPosition(this);
|
||||
var delta = new Point(DragOrigin.X - end.X, DragOrigin.Y - end.Y);
|
||||
|
||||
var l = Canvas.GetLeft(Map) - delta.X;
|
||||
var t = Canvas.GetTop(Map) - delta.Y;
|
||||
|
||||
if (DisableAnimations)
|
||||
{
|
||||
Canvas.SetLeft(Map, l);
|
||||
Canvas.SetTop(Map, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(l, AnimationsSpeed));
|
||||
Map.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(t, AnimationsSpeed));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [land click].
|
||||
/// </summary>
|
||||
public event Action<object, MapData> LandClick;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
private Canvas Canvas { get; set; }
|
||||
private Canvas Map { get; set; }
|
||||
private Point DragOrigin { get; set; }
|
||||
private Point OriginalPosition { get; set; }
|
||||
private bool IsDrawn { get; set; }
|
||||
private bool IsWidthDominant { get; set; }
|
||||
private Dictionary<string, MapData> Lands { get; set; }
|
||||
|
||||
private static readonly DependencyProperty GeoMapTooltipProperty = DependencyProperty.Register(
|
||||
"GeoMapTooltip", typeof (DefaultGeoMapTooltip), typeof (GeoMap), new PropertyMetadata(default(DefaultGeoMapTooltip)));
|
||||
private DefaultGeoMapTooltip GeoMapTooltip
|
||||
{
|
||||
get { return (DefaultGeoMapTooltip) GetValue(GeoMapTooltipProperty); }
|
||||
set { SetValue(GeoMapTooltipProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The language pack property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LanguagePackProperty = DependencyProperty.Register(
|
||||
"LanguagePack", typeof (Dictionary<string, string>), typeof (GeoMap), new PropertyMetadata(default(Dictionary<string, string>)));
|
||||
/// <summary>
|
||||
/// Gets or sets the language dictionary
|
||||
/// </summary>
|
||||
public Dictionary<string, string> LanguagePack
|
||||
{
|
||||
get { return (Dictionary<string, string>) GetValue(LanguagePackProperty); }
|
||||
set { SetValue(LanguagePackProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default land fill property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DefaultLandFillProperty = DependencyProperty.Register(
|
||||
"DefaultLandFill", typeof (Brush), typeof (GeoMap), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets default land fill
|
||||
/// </summary>
|
||||
public Brush DefaultLandFill
|
||||
{
|
||||
get { return (Brush) GetValue(DefaultLandFillProperty); }
|
||||
set { SetValue(DefaultLandFillProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The land stroke thickness property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LandStrokeThicknessProperty = DependencyProperty.Register(
|
||||
"LandStrokeThickness", typeof (double), typeof (GeoMap), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets every land stroke thickness property
|
||||
/// </summary>
|
||||
public double LandStrokeThickness
|
||||
{
|
||||
get { return (double) GetValue(LandStrokeThicknessProperty); }
|
||||
set { SetValue(LandStrokeThicknessProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The land stroke property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LandStrokeProperty = DependencyProperty.Register(
|
||||
"LandStroke", typeof (Brush), typeof (GeoMap), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets every land stroke
|
||||
/// </summary>
|
||||
public Brush LandStroke
|
||||
{
|
||||
get { return (Brush) GetValue(LandStrokeProperty); }
|
||||
set { SetValue(LandStrokeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The disable animations property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DisableAnimationsProperty = DependencyProperty.Register(
|
||||
"DisableAnimations", typeof (bool), typeof (GeoMap), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets whether the chart is animated
|
||||
/// </summary>
|
||||
public bool DisableAnimations
|
||||
{
|
||||
get { return (bool) GetValue(DisableAnimationsProperty); }
|
||||
set { SetValue(DisableAnimationsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The animations speed property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty AnimationsSpeedProperty = DependencyProperty.Register(
|
||||
"AnimationsSpeed", typeof (TimeSpan), typeof (GeoMap), new PropertyMetadata(default(TimeSpan)));
|
||||
/// <summary>
|
||||
/// Gets or sets animations speed
|
||||
/// </summary>
|
||||
public TimeSpan AnimationsSpeed
|
||||
{
|
||||
get { return (TimeSpan) GetValue(AnimationsSpeedProperty); }
|
||||
set { SetValue(AnimationsSpeedProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The hoverable property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HoverableProperty = DependencyProperty.Register(
|
||||
"Hoverable", typeof (bool), typeof (GeoMap), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets whether the chart reacts when a user moves the mouse over a land
|
||||
/// </summary>
|
||||
public bool Hoverable
|
||||
{
|
||||
get { return (bool) GetValue(HoverableProperty); }
|
||||
set { SetValue(HoverableProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The heat map property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HeatMapProperty = DependencyProperty.Register(
|
||||
"HeatMap", typeof (Dictionary<string, double>), typeof (GeoMap),
|
||||
new PropertyMetadata(default(Dictionary<string, double>), OnHeapMapChanged));
|
||||
/// <summary>
|
||||
/// Gets or sets the current heat map
|
||||
/// </summary>
|
||||
public Dictionary<string, double> HeatMap
|
||||
{
|
||||
get { return (Dictionary<string, double>) GetValue(HeatMapProperty); }
|
||||
set { SetValue(HeatMapProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The gradient stop collection property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty GradientStopCollectionProperty = DependencyProperty.Register(
|
||||
"GradientStopCollection", typeof(GradientStopCollection), typeof(GeoMap), new PropertyMetadata(default(GradientStopCollection)));
|
||||
/// <summary>
|
||||
/// Gets or sets the gradient stop collection, use every gradient offset and color properties to define your gradient.
|
||||
/// </summary>
|
||||
public GradientStopCollection GradientStopCollection
|
||||
{
|
||||
get { return (GradientStopCollection)GetValue(GradientStopCollectionProperty); }
|
||||
set { SetValue(GradientStopCollectionProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The source property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
|
||||
"Source", typeof (string), typeof (GeoMap), new PropertyMetadata(default(string)));
|
||||
/// <summary>
|
||||
/// Gets or sets the map source
|
||||
/// </summary>
|
||||
public string Source
|
||||
{
|
||||
get { return (string) GetValue(SourceProperty); }
|
||||
set { SetValue(SourceProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The enable zooming and panning property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty EnableZoomingAndPanningProperty = DependencyProperty.Register(
|
||||
"EnableZoomingAndPanning", typeof (bool), typeof (GeoMap), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets whether the map allows zooming and panning
|
||||
/// </summary>
|
||||
public bool EnableZoomingAndPanning
|
||||
{
|
||||
get { return (bool) GetValue(EnableZoomingAndPanningProperty); }
|
||||
set { SetValue(EnableZoomingAndPanningProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Publics
|
||||
|
||||
///// <summary>
|
||||
///// Moves the map to a specif area
|
||||
///// </summary>
|
||||
///// <param name="data">target area</param>
|
||||
//public void MoveTo(MapData data)
|
||||
//{
|
||||
// var s = (Path) data.Shape;
|
||||
// var area = s.Data.Bounds;
|
||||
// var t = (ScaleTransform) s.RenderTransform;
|
||||
|
||||
|
||||
|
||||
// //if (DisableAnimations)
|
||||
// //{
|
||||
|
||||
// double scale;
|
||||
// double cx = 0;
|
||||
// double cy = 0;
|
||||
|
||||
// if (IsWidthDominant)
|
||||
// {
|
||||
// scale = data.LvcMap.DesiredWidth / area.Width;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// scale = data.LvcMap.DesiredHeight / area.Height;
|
||||
// }
|
||||
|
||||
// Map.RenderTransformOrigin = new Point(0, 0);
|
||||
// Map.RenderTransform = new ScaleTransform(scale, scale);
|
||||
|
||||
// Canvas.SetLeft(Map, -area.X*t.ScaleX*scale + cx);
|
||||
// Canvas.SetTop(Map, -area.Y*t.ScaleY*scale + cy);
|
||||
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // Map.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(-area.X, AnimationsSpeed));
|
||||
// // //Map.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(area.Y, AnimationsSpeed));
|
||||
// //}
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Restarts the current map view
|
||||
/// </summary>
|
||||
public void Restart()
|
||||
{
|
||||
Map.RenderTransform = new ScaleTransform(1, 1);
|
||||
if (DisableAnimations)
|
||||
{
|
||||
Canvas.SetLeft(Map, OriginalPosition.X);
|
||||
Canvas.SetTop(Map, OriginalPosition.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(OriginalPosition.X, TimeSpan.FromMilliseconds(1)));
|
||||
Map.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(OriginalPosition.Y, TimeSpan.FromMilliseconds(1)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a heat map value with a given key, then updates every land heat color
|
||||
/// </summary>
|
||||
/// <param name="key">key</param>
|
||||
/// <param name="value">new value</param>
|
||||
public void UpdateKey(string key, double value)
|
||||
{
|
||||
HeatMap[key] = value;
|
||||
ShowMeSomeHeat();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Privates
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
IsDrawn = true;
|
||||
|
||||
Map.Children.Clear();
|
||||
|
||||
if (DesignerProperties.GetIsInDesignMode(this))
|
||||
{
|
||||
Map.Children.Add(new TextBlock
|
||||
{
|
||||
Text = "Designer preview is not currently available",
|
||||
Foreground = Brushes.White,
|
||||
FontWeight = FontWeights.Bold,
|
||||
FontSize = 12,
|
||||
Effect = new DropShadowEffect
|
||||
{
|
||||
ShadowDepth = 2,
|
||||
RenderingBias = RenderingBias.Performance
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var map = MapResolver.Get(Source);
|
||||
if (map == null) return;
|
||||
|
||||
var desiredSize = new Size(map.DesiredWidth, map.DesiredHeight);
|
||||
var r = desiredSize.Width/desiredSize.Height;
|
||||
|
||||
var wr = ActualWidth/desiredSize.Width;
|
||||
var hr = ActualHeight/desiredSize.Height;
|
||||
double s;
|
||||
|
||||
if (wr < hr)
|
||||
{
|
||||
IsWidthDominant = true;
|
||||
Map.Width = ActualWidth;
|
||||
Map.Height = Map.Width/r;
|
||||
s = wr;
|
||||
OriginalPosition = new Point(0, (ActualHeight - Map.Height)*.5);
|
||||
Canvas.SetLeft(Map, OriginalPosition.X);
|
||||
Canvas.SetTop(Map, OriginalPosition.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
IsWidthDominant = false;
|
||||
Map.Height = ActualHeight;
|
||||
Map.Width = r*ActualHeight;
|
||||
s = hr;
|
||||
OriginalPosition = new Point((ActualWidth - Map.Width)*.5, 0d);
|
||||
Canvas.SetLeft(Map, OriginalPosition.X);
|
||||
Canvas.SetTop(Map, OriginalPosition.Y);
|
||||
}
|
||||
|
||||
var t = new ScaleTransform(s, s);
|
||||
|
||||
foreach (var land in map.Data)
|
||||
{
|
||||
var p = new Path
|
||||
{
|
||||
Data = Geometry.Parse(land.Data),
|
||||
RenderTransform = t
|
||||
};
|
||||
|
||||
land.Shape = p;
|
||||
Lands[land.Id] = land;
|
||||
Map.Children.Add(p);
|
||||
|
||||
p.MouseEnter += POnMouseEnter;
|
||||
p.MouseLeave += POnMouseLeave;
|
||||
p.MouseMove += POnMouseMove;
|
||||
p.MouseDown += POnMouseDown;
|
||||
|
||||
p.SetBinding(Shape.StrokeProperty,
|
||||
new Binding { Path = new PropertyPath(LandStrokeProperty), Source = this });
|
||||
p.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new MultiBinding
|
||||
{
|
||||
Converter = new ScaleStrokeConverter(),
|
||||
Bindings =
|
||||
{
|
||||
new Binding("LandStrokeThickness") {Source = this},
|
||||
new Binding("ScaleX") {Source = t}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
ShowMeSomeHeat();
|
||||
}
|
||||
|
||||
private void ShowMeSomeHeat()
|
||||
{
|
||||
var max = double.MinValue;
|
||||
var min = double.MaxValue;
|
||||
|
||||
foreach (var i in HeatMap.Values)
|
||||
{
|
||||
max = i > max ? i : max;
|
||||
min = i < min ? i : min;
|
||||
}
|
||||
|
||||
foreach (var land in Lands)
|
||||
{
|
||||
double temperature;
|
||||
var shape = ((Shape) land.Value.Shape);
|
||||
|
||||
shape.SetBinding(Shape.FillProperty,
|
||||
new Binding {Path = new PropertyPath(DefaultLandFillProperty), Source = this});
|
||||
|
||||
if (!HeatMap.TryGetValue(land.Key, out temperature)) continue;
|
||||
|
||||
temperature = LinealInterpolation(0, 1, min, max, temperature);
|
||||
var color = ColorInterpolation(temperature);
|
||||
|
||||
if (DisableAnimations)
|
||||
{
|
||||
shape.Fill = new SolidColorBrush(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
shape.Fill = new SolidColorBrush();
|
||||
((SolidColorBrush) shape.Fill).BeginAnimation(SolidColorBrush.ColorProperty,
|
||||
new ColorAnimation(color, AnimationsSpeed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void POnMouseDown(object sender, MouseButtonEventArgs mouseButtonEventArgs)
|
||||
{
|
||||
var land = Lands.Values.FirstOrDefault(x => x.Shape == sender);
|
||||
if (land == null) return;
|
||||
|
||||
if (LandClick != null) LandClick.Invoke(sender, land);
|
||||
}
|
||||
|
||||
private void POnMouseLeave(object sender, MouseEventArgs mouseEventArgs)
|
||||
{
|
||||
var path = (Path)sender;
|
||||
path.Opacity = 1;
|
||||
|
||||
GeoMapTooltip.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void POnMouseEnter(object sender, MouseEventArgs mouseEventArgs)
|
||||
{
|
||||
var path = (Path) sender;
|
||||
path.Opacity = .8;
|
||||
|
||||
var land = Lands.Values.FirstOrDefault(x => x.Shape == sender);
|
||||
if (land == null) return;
|
||||
|
||||
double value;
|
||||
|
||||
if (!HeatMap.TryGetValue(land.Id, out value)) return;
|
||||
if (!Hoverable) return;
|
||||
|
||||
GeoMapTooltip.Visibility = Visibility.Visible;
|
||||
|
||||
string name = null;
|
||||
|
||||
if (LanguagePack != null) LanguagePack.TryGetValue(land.Id, out name);
|
||||
|
||||
GeoMapTooltip.GeoData = new GeoData
|
||||
{
|
||||
Name = name ?? land.Name,
|
||||
Value = value
|
||||
};
|
||||
}
|
||||
|
||||
private void POnMouseMove(object sender, MouseEventArgs mouseEventArgs)
|
||||
{
|
||||
var location = mouseEventArgs.GetPosition(this);
|
||||
Canvas.SetTop(GeoMapTooltip, location.Y + 5);
|
||||
Canvas.SetLeft(GeoMapTooltip, location.X + 5);
|
||||
}
|
||||
|
||||
private Color ColorInterpolation(double weight)
|
||||
{
|
||||
Color from = Color.FromRgb(0, 0, 0), to = Color.FromRgb(0, 0, 0);
|
||||
double fromOffset = 0, toOffset = 0;
|
||||
|
||||
for (var i = 0; i < GradientStopCollection.Count-1; i++)
|
||||
{
|
||||
// ReSharper disable once InvertIf
|
||||
if (GradientStopCollection[i].Offset <= weight && GradientStopCollection[i + 1].Offset >= weight)
|
||||
{
|
||||
from = GradientStopCollection[i].Color;
|
||||
to = GradientStopCollection[i + 1].Color;
|
||||
|
||||
fromOffset = GradientStopCollection[i].Offset;
|
||||
toOffset = GradientStopCollection[i + 1].Offset;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Color.FromArgb(
|
||||
(byte) LinealInterpolation(from.A, to.A, fromOffset, toOffset, weight),
|
||||
(byte) LinealInterpolation(from.R, to.R, fromOffset, toOffset, weight),
|
||||
(byte) LinealInterpolation(from.G, to.G, fromOffset, toOffset, weight),
|
||||
(byte) LinealInterpolation(from.B, to.B, fromOffset, toOffset, weight));
|
||||
}
|
||||
|
||||
private static double LinealInterpolation(double fromComponent, double toComponent,
|
||||
double fromOffset, double toOffset, double value)
|
||||
{
|
||||
var p1 = new Point(fromOffset, fromComponent);
|
||||
var p2 = new Point(toOffset, toComponent);
|
||||
|
||||
var deltaX = p2.X - p1.X;
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
||||
var m = (p2.Y - p1.Y) / (deltaX == 0 ? double.MinValue : deltaX);
|
||||
|
||||
return m * (value - p1.X) + p1.Y;
|
||||
}
|
||||
|
||||
private static void OnHeapMapChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var geoMap = (GeoMap)o;
|
||||
|
||||
if (!geoMap.IsDrawn) return;
|
||||
|
||||
geoMap.ShowMeSomeHeat();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Data.IMultiValueConverter" />
|
||||
public class ScaleStrokeConverter : IMultiValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
|
||||
/// </summary>
|
||||
/// <param name="values">The array of values that the source bindings in the <see cref="T:System.Windows.Data.MultiBinding" /> produces. The value <see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the source binding has no value to provide for conversion.</param>
|
||||
/// <param name="targetType">The type of the binding target property.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// A converted value.If the method returns null, the valid null value is used.A return value of <see cref="T:System.Windows.DependencyProperty" />.<see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the converter did not produce a value, and that the binding will use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> if it is available, or else will use the default value.A return value of <see cref="T:System.Windows.Data.Binding" />.<see cref="F:System.Windows.Data.Binding.DoNothing" /> indicates that the binding does not transfer the value or use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> or the default value.
|
||||
/// </returns>
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (double) values[0]/(double) values[1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a binding target value to the source binding values.
|
||||
/// </summary>
|
||||
/// <param name="value">The value that the binding target produces.</param>
|
||||
/// <param name="targetTypes">The array of types to convert to. The array length indicates the number and types of values that are suggested for the method to return.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>
|
||||
/// An array of values that have been converted from the target value back to the source values.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Others/Live-Charts-master/WpfView/HeatColorRange.xaml
Normal file
14
Others/Live-Charts-master/WpfView/HeatColorRange.xaml
Normal file
@@ -0,0 +1,14 @@
|
||||
<UserControl x:Class="LiveCharts.Wpf.HeatColorRange"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:LiveCharts.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="100" d:DesignWidth="50" d:DataContext="{d:DesignInstance local:HeatColorRange}"
|
||||
Width="Auto">
|
||||
<Grid>
|
||||
<TextBlock Name="MinVal" Padding="5 0" HorizontalAlignment="Center" Text="{Binding Min}"/>
|
||||
<TextBlock Name="MaxVal" Padding="5 0" VerticalAlignment="Bottom" HorizontalAlignment="Center" Text="{Binding Max}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
79
Others/Live-Charts-master/WpfView/HeatColorRange.xaml.cs
Normal file
79
Others/Live-Charts-master/WpfView/HeatColorRange.xaml.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for HeatColorRange.xaml
|
||||
/// </summary>
|
||||
public partial class HeatColorRange
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HeatColorRange"/> class.
|
||||
/// </summary>
|
||||
public HeatColorRange()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the fill.
|
||||
/// </summary>
|
||||
/// <param name="stops">The stops.</param>
|
||||
public void UpdateFill(GradientStopCollection stops)
|
||||
{
|
||||
Background = new LinearGradientBrush
|
||||
{
|
||||
StartPoint = new Point(0, 0),
|
||||
EndPoint = new Point(0, 1),
|
||||
GradientStops = stops
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the maximum.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
public double SetMax(string value)
|
||||
{
|
||||
MaxVal.Text = value;
|
||||
MaxVal.UpdateLayout();
|
||||
return MaxVal.ActualWidth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the minimum.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
public double SetMin(string value)
|
||||
{
|
||||
MinVal.Text = value;
|
||||
MinVal.UpdateLayout();
|
||||
return MinVal.ActualWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
327
Others/Live-Charts-master/WpfView/HeatSeries.cs
Normal file
327
Others/Live-Charts-master/WpfView/HeatSeries.cs
Normal file
@@ -0,0 +1,327 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
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.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Use a HeatSeries in a cartesian chart to draw heat maps.
|
||||
/// </summary>
|
||||
public class HeatSeries : Series, IHeatSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of HeatSeries class
|
||||
/// </summary>
|
||||
public HeatSeries()
|
||||
{
|
||||
Model = new HeatAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of HeatSries class, using a given mapper
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public HeatSeries(object configuration)
|
||||
{
|
||||
Model = new HeatAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private HeatColorRange ColorRangeControl { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The draws heat range property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DrawsHeatRangeProperty = DependencyProperty.Register(
|
||||
"DrawsHeatRange", typeof(bool), typeof(HeatSeries),
|
||||
new PropertyMetadata(default(bool), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets whether the series should draw the heat range control, it is the vertical frame to the right that displays the heat gradient.
|
||||
/// </summary>
|
||||
public bool DrawsHeatRange
|
||||
{
|
||||
get { return (bool)GetValue(DrawsHeatRangeProperty); }
|
||||
set { SetValue(DrawsHeatRangeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The gradient stop collection property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty GradientStopCollectionProperty = DependencyProperty.Register(
|
||||
"GradientStopCollection", typeof(GradientStopCollection), typeof(HeatSeries), new PropertyMetadata(default(GradientStopCollection)));
|
||||
/// <summary>
|
||||
/// Gets or sets the gradient stop collection, use every gradient offset and color properties to define your gradient.
|
||||
/// </summary>
|
||||
public GradientStopCollection GradientStopCollection
|
||||
{
|
||||
get { return (GradientStopCollection)GetValue(GradientStopCollectionProperty); }
|
||||
set { SetValue(GradientStopCollectionProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the gradient stops, this property is normally used internally to communicate with the core of the library.
|
||||
/// </summary>
|
||||
public IList<CoreGradientStop> Stops
|
||||
{
|
||||
get
|
||||
{
|
||||
return GradientStopCollection.Select(x => new CoreGradientStop
|
||||
{
|
||||
Offset = x.Offset,
|
||||
Color = new CoreColor(x.Color.A, x.Color.R, x.Color.G, x.Color.B)
|
||||
}).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (HeatPoint) point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new HeatPoint
|
||||
{
|
||||
IsNew = true,
|
||||
Rectangle = new Rectangle()
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Rectangle);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
pbv.Rectangle.Stroke = Stroke;
|
||||
pbv.Rectangle.StrokeThickness = StrokeThickness;
|
||||
pbv.Rectangle.Visibility = Visibility;
|
||||
pbv.Rectangle.StrokeDashArray = StrokeDashArray;
|
||||
Panel.SetZIndex(pbv.Rectangle, Panel.GetZIndex(pbv.Rectangle));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Erases series
|
||||
/// </summary>
|
||||
/// <param name="removeFromView"></param>
|
||||
public override void Erase(bool removeFromView = true)
|
||||
{
|
||||
Values.GetPoints(this).ForEach(p =>
|
||||
{
|
||||
if (p.View != null)
|
||||
p.View.RemoveFromView(Model.Chart);
|
||||
});
|
||||
if (removeFromView) Model.Chart.View.RemoveFromView(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines special elements to draw according to the series type
|
||||
/// </summary>
|
||||
public override void DrawSpecializedElements()
|
||||
{
|
||||
if (DrawsHeatRange)
|
||||
{
|
||||
if (ColorRangeControl == null)
|
||||
{
|
||||
ColorRangeControl = new HeatColorRange();
|
||||
}
|
||||
|
||||
ColorRangeControl.SetBinding(TextBlock.FontFamilyProperty,
|
||||
new Binding {Path = new PropertyPath(FontFamilyProperty), Source = this});
|
||||
ColorRangeControl.SetBinding(TextBlock.FontSizeProperty,
|
||||
new Binding { Path = new PropertyPath(FontSizeProperty), Source = this });
|
||||
ColorRangeControl.SetBinding(TextBlock.FontStretchProperty,
|
||||
new Binding { Path = new PropertyPath(FontStretchProperty), Source = this });
|
||||
ColorRangeControl.SetBinding(TextBlock.FontStyleProperty,
|
||||
new Binding { Path = new PropertyPath(FontStyleProperty), Source = this });
|
||||
ColorRangeControl.SetBinding(TextBlock.FontWeightProperty,
|
||||
new Binding { Path = new PropertyPath(FontWeightProperty), Source = this });
|
||||
ColorRangeControl.SetBinding(TextBlock.ForegroundProperty,
|
||||
new Binding { Path = new PropertyPath(ForegroundProperty), Source = this });
|
||||
ColorRangeControl.SetBinding(VisibilityProperty,
|
||||
new Binding { Path = new PropertyPath(VisibilityProperty), Source = this });
|
||||
|
||||
if (ColorRangeControl.Parent == null)
|
||||
{
|
||||
Model.Chart.View.AddToView(ColorRangeControl);
|
||||
}
|
||||
var max = ColorRangeControl.SetMax(ActualValues.GetTracker(this).WLimit.Max.ToString(CultureInfo.InvariantCulture));
|
||||
var min = ColorRangeControl.SetMin(ActualValues.GetTracker(this).WLimit.Min.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
var m = max > min ? max : min;
|
||||
|
||||
ColorRangeControl.Width = m;
|
||||
|
||||
Model.Chart.ControlSize = new CoreSize(Model.Chart.ControlSize.Width - m - 4,
|
||||
Model.Chart.ControlSize.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
Model.Chart.View.RemoveFromView(ColorRangeControl);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places specializes items
|
||||
/// </summary>
|
||||
public override void PlaceSpecializedElements()
|
||||
{
|
||||
if (!DrawsHeatRange) return;
|
||||
|
||||
ColorRangeControl.UpdateFill(GradientStopCollection);
|
||||
|
||||
ColorRangeControl.Height = Model.Chart.DrawMargin.Height;
|
||||
|
||||
Canvas.SetTop(ColorRangeControl, Model.Chart.DrawMargin.Top);
|
||||
Canvas.SetLeft(ColorRangeControl, Model.Chart.DrawMargin.Left + Model.Chart.DrawMargin.Width + 4);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
SetCurrentValue(ForegroundProperty, Brushes.White);
|
||||
SetCurrentValue(StrokeProperty, Brushes.White);
|
||||
SetCurrentValue(DrawsHeatRangeProperty, true);
|
||||
SetCurrentValue(GradientStopCollectionProperty, new GradientStopCollection());
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => x.Weight.ToString(CultureInfo.InvariantCulture);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.4;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the series colors if they are not set
|
||||
/// </summary>
|
||||
public override void InitializeColors()
|
||||
{
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
var nextColor = wpfChart.GetNextDefaultColor();
|
||||
|
||||
if (Stroke == null)
|
||||
SetValue(StrokeProperty, new SolidColorBrush(nextColor));
|
||||
if (Fill == null)
|
||||
SetValue(FillProperty, new SolidColorBrush(nextColor));
|
||||
|
||||
var defaultColdColor = new Color
|
||||
{
|
||||
A = (byte)(nextColor.A * (DefaultFillOpacity > 1
|
||||
? 1
|
||||
: (DefaultFillOpacity < 0 ? 0 : DefaultFillOpacity))),
|
||||
R = nextColor.R,
|
||||
G = nextColor.G,
|
||||
B = nextColor.B
|
||||
};
|
||||
|
||||
if (!GradientStopCollection.Any())
|
||||
{
|
||||
GradientStopCollection.Add(new GradientStop
|
||||
{
|
||||
Color = defaultColdColor,
|
||||
Offset = 0
|
||||
});
|
||||
GradientStopCollection.Add(new GradientStop
|
||||
{
|
||||
Color = nextColor,
|
||||
Offset = 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
42
Others/Live-Charts-master/WpfView/IChartLegend.cs
Normal file
42
Others/Live-Charts-master/WpfView/IChartLegend.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.ComponentModel.INotifyPropertyChanged" />
|
||||
public interface IChartLegend : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the series.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The series.
|
||||
/// </value>
|
||||
List<SeriesViewModel> Series { get; set; }
|
||||
}
|
||||
}
|
||||
48
Others/Live-Charts-master/WpfView/IChartTooltip.cs
Normal file
48
Others/Live-Charts-master/WpfView/IChartTooltip.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.ComponentModel.INotifyPropertyChanged" />
|
||||
public interface IChartTooltip : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the data.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The data.
|
||||
/// </value>
|
||||
TooltipData Data { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the selection mode.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The selection mode.
|
||||
/// </value>
|
||||
TooltipSelectionMode? SelectionMode { get; set; }
|
||||
}
|
||||
}
|
||||
42
Others/Live-Charts-master/WpfView/LineSegmentSplitter.cs
Normal file
42
Others/Live-Charts-master/WpfView/LineSegmentSplitter.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
internal class LineSegmentSplitter
|
||||
{
|
||||
public LineSegmentSplitter()
|
||||
{
|
||||
Bottom = new LineSegment { IsStroked = false };
|
||||
Left = new LineSegment { IsStroked = false };
|
||||
Right = new LineSegment { IsStroked = false };
|
||||
}
|
||||
|
||||
public LineSegment Bottom { get; private set; }
|
||||
public LineSegment Left { get; private set; }
|
||||
public LineSegment Right { get; private set; }
|
||||
public int SplitterCollectorIndex { get; set; }
|
||||
public bool IsNew { get; set; }
|
||||
}
|
||||
}
|
||||
498
Others/Live-Charts-master/WpfView/LineSeries.cs
Normal file
498
Others/Live-Charts-master/WpfView/LineSeries.cs
Normal file
@@ -0,0 +1,498 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
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>
|
||||
/// The line series displays trends between points, you must add this series to a cartesian chart.
|
||||
/// </summary>
|
||||
public class LineSeries : Series, ILineSeriesView, IFondeable, IAreaPoint
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of LineSeries class
|
||||
/// </summary>
|
||||
public LineSeries()
|
||||
{
|
||||
Model = new LineAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of LineSeries class with a given mapper
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public LineSeries(object configuration)
|
||||
{
|
||||
Model = new LineAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the figure.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The figure.
|
||||
/// </value>
|
||||
protected PathFigure Figure { get; set; }
|
||||
internal Path Path { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is path initialized.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is path initialized; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
protected bool IsPathInitialized { get; set; }
|
||||
internal List<LineSegmentSplitter> Splitters { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the active splitters.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The active splitters.
|
||||
/// </value>
|
||||
protected int ActiveSplitters { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the splitters collector.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The splitters collector.
|
||||
/// </value>
|
||||
protected int SplittersCollector { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is new.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is new; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
protected bool IsNew { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The point geometry size property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PointGeometrySizeProperty = DependencyProperty.Register(
|
||||
"PointGeometrySize", typeof (double), typeof (LineSeries),
|
||||
new PropertyMetadata(default(double), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the point geometry size, increasing this property will make the series points bigger
|
||||
/// </summary>
|
||||
public double PointGeometrySize
|
||||
{
|
||||
get { return (double) GetValue(PointGeometrySizeProperty); }
|
||||
set { SetValue(PointGeometrySizeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The point foreground property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PointForegroundProperty = DependencyProperty.Register(
|
||||
"PointForeground", typeof (Brush), typeof (LineSeries),
|
||||
new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the point shape foreground.
|
||||
/// </summary>
|
||||
public Brush PointForeground
|
||||
{
|
||||
get { return (Brush) GetValue(PointForegroundProperty); }
|
||||
set { SetValue(PointForegroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The line smoothness property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LineSmoothnessProperty = DependencyProperty.Register(
|
||||
"LineSmoothness", typeof (double), typeof (LineSeries),
|
||||
new PropertyMetadata(default(double), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets line smoothness, this property goes from 0 to 1, use 0 to draw straight lines, 1 really curved lines.
|
||||
/// </summary>
|
||||
public double LineSmoothness
|
||||
{
|
||||
get { return (double) GetValue(LineSmoothnessProperty); }
|
||||
set { SetValue(LineSmoothnessProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The area limit property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty AreaLimitProperty = DependencyProperty.Register(
|
||||
"AreaLimit", typeof(double), typeof(LineSeries), new PropertyMetadata(double.NaN));
|
||||
/// <summary>
|
||||
/// Gets or sets the limit where the fill area changes orientation
|
||||
/// </summary>
|
||||
public double AreaLimit
|
||||
{
|
||||
get { return (double) GetValue(AreaLimitProperty); }
|
||||
set { SetValue(AreaLimitProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// This method runs when the update starts
|
||||
/// </summary>
|
||||
public override void OnSeriesUpdateStart()
|
||||
{
|
||||
ActiveSplitters = 0;
|
||||
|
||||
if (SplittersCollector == int.MaxValue - 1)
|
||||
{
|
||||
//just in case!
|
||||
Splitters.ForEach(s => s.SplitterCollectorIndex = 0);
|
||||
SplittersCollector = 0;
|
||||
}
|
||||
|
||||
SplittersCollector++;
|
||||
|
||||
if (IsPathInitialized)
|
||||
{
|
||||
Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(Path);
|
||||
Path.Stroke = Stroke;
|
||||
Path.StrokeThickness = StrokeThickness;
|
||||
Path.Fill = Fill;
|
||||
Path.Visibility = Visibility;
|
||||
Path.StrokeDashArray = StrokeDashArray;
|
||||
Panel.SetZIndex(Path, Panel.GetZIndex(this));
|
||||
return;
|
||||
}
|
||||
|
||||
IsPathInitialized = true;
|
||||
|
||||
Path = new Path
|
||||
{
|
||||
Stroke = Stroke,
|
||||
StrokeThickness = StrokeThickness,
|
||||
Fill = Fill,
|
||||
Visibility = Visibility,
|
||||
StrokeDashArray = StrokeDashArray
|
||||
};
|
||||
|
||||
Panel.SetZIndex(Path, Panel.GetZIndex(this));
|
||||
|
||||
var geometry = new PathGeometry();
|
||||
Figure = new PathFigure();
|
||||
geometry.Figures.Add(Figure);
|
||||
Path.Data = geometry;
|
||||
|
||||
Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(Path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var mhr = PointGeometrySize < 10 ? 10 : PointGeometrySize;
|
||||
|
||||
var pbv = (HorizontalBezierPointView) point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new HorizontalBezierPointView
|
||||
{
|
||||
Segment = new BezierSegment(),
|
||||
Container = Figure,
|
||||
IsNew = true
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Shape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0,
|
||||
Width = mhr,
|
||||
Height = mhr
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (PointGeometry != null && Math.Abs(PointGeometrySize) > 0.1 && pbv.Shape == null)
|
||||
{
|
||||
if (PointGeometry != null)
|
||||
{
|
||||
pbv.Shape = new Path
|
||||
{
|
||||
Stretch = Stretch.Fill,
|
||||
StrokeThickness = StrokeThickness
|
||||
};
|
||||
}
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Shape);
|
||||
}
|
||||
|
||||
if (pbv.Shape != null)
|
||||
{
|
||||
pbv.Shape.Fill = PointForeground;
|
||||
pbv.Shape.Stroke = Stroke;
|
||||
pbv.Shape.StrokeThickness = StrokeThickness;
|
||||
pbv.Shape.Width = PointGeometrySize;
|
||||
pbv.Shape.Height = PointGeometrySize;
|
||||
pbv.Shape.Data = PointGeometry;
|
||||
pbv.Shape.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.Shape, Panel.GetZIndex(this) + 1);
|
||||
|
||||
if (point.Stroke != null) pbv.Shape.Stroke = (Brush) point.Stroke;
|
||||
if (point.Fill != null) pbv.Shape.Fill = (Brush) point.Fill;
|
||||
}
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method runs when the update finishes
|
||||
/// </summary>
|
||||
public override void OnSeriesUpdatedFinish()
|
||||
{
|
||||
base.OnSeriesUpdatedFinish();
|
||||
|
||||
foreach (var inactive in Splitters
|
||||
.Where(s => s.SplitterCollectorIndex < SplittersCollector).ToList())
|
||||
{
|
||||
Figure.Segments.Remove(inactive.Left);
|
||||
Figure.Segments.Remove(inactive.Bottom);
|
||||
Figure.Segments.Remove(inactive.Right);
|
||||
Splitters.Remove(inactive);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Erases series
|
||||
/// </summary>
|
||||
/// <param name="removeFromView"></param>
|
||||
public override void Erase(bool removeFromView = true)
|
||||
{
|
||||
ActualValues.GetPoints(this).ForEach(p =>
|
||||
{
|
||||
if (p.View != null)
|
||||
p.View.RemoveFromView(Model.Chart);
|
||||
});
|
||||
if (Path != null) Path.Visibility = Visibility.Hidden;
|
||||
if (removeFromView)
|
||||
{
|
||||
Model.Chart.View.RemoveFromDrawMargin(Path);
|
||||
Model.Chart.View.RemoveFromView(this);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Gets the point diameter.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public double GetPointDiameter()
|
||||
{
|
||||
return (PointGeometry == null ? 0 : PointGeometrySize)/2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the segment.
|
||||
/// </summary>
|
||||
/// <param name="atIndex">At index.</param>
|
||||
/// <param name="location">The location.</param>
|
||||
public virtual void StartSegment(int atIndex, CorePoint location)
|
||||
{
|
||||
if (Splitters.Count <= ActiveSplitters)
|
||||
Splitters.Add(new LineSegmentSplitter {IsNew = true});
|
||||
|
||||
var splitter = Splitters[ActiveSplitters];
|
||||
splitter.SplitterCollectorIndex = SplittersCollector;
|
||||
|
||||
ActiveSplitters++;
|
||||
var animSpeed = Model.Chart.View.AnimationsSpeed;
|
||||
var noAnim = Model.Chart.View.DisableAnimations;
|
||||
|
||||
var areaLimit = ChartFunctions.ToDrawMargin(double.IsNaN(AreaLimit)
|
||||
? Model.Chart.AxisY[ScalesYAt].FirstSeparator
|
||||
: AreaLimit, AxisOrientation.Y, Model.Chart, ScalesYAt);
|
||||
|
||||
if (Values != null && atIndex == 0)
|
||||
{
|
||||
if (Model.Chart.View.DisableAnimations || IsNew)
|
||||
Figure.StartPoint = new Point(location.X, areaLimit);
|
||||
else
|
||||
Figure.BeginAnimation(PathFigure.StartPointProperty,
|
||||
new PointAnimation(new Point(location.X, areaLimit), animSpeed));
|
||||
|
||||
IsNew = false;
|
||||
}
|
||||
|
||||
if (atIndex != 0)
|
||||
{
|
||||
Figure.Segments.Remove(splitter.Bottom);
|
||||
|
||||
if (splitter.IsNew)
|
||||
{
|
||||
splitter.Bottom.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
|
||||
splitter.Left.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
|
||||
}
|
||||
|
||||
if (noAnim)
|
||||
splitter.Bottom.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
|
||||
else
|
||||
splitter.Bottom.BeginAnimation(LineSegment.PointProperty,
|
||||
new PointAnimation(new Point(location.X, Model.Chart.DrawMargin.Height), animSpeed));
|
||||
Figure.Segments.Insert(atIndex, splitter.Bottom);
|
||||
|
||||
Figure.Segments.Remove(splitter.Left);
|
||||
if (noAnim)
|
||||
splitter.Left.Point = location.AsPoint();
|
||||
else
|
||||
splitter.Left.BeginAnimation(LineSegment.PointProperty,
|
||||
new PointAnimation(location.AsPoint(), animSpeed));
|
||||
Figure.Segments.Insert(atIndex + 1, splitter.Left);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (splitter.IsNew)
|
||||
{
|
||||
splitter.Bottom.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
|
||||
splitter.Left.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
|
||||
}
|
||||
|
||||
Figure.Segments.Remove(splitter.Left);
|
||||
if (Model.Chart.View.DisableAnimations)
|
||||
splitter.Left.Point = location.AsPoint();
|
||||
else
|
||||
splitter.Left.BeginAnimation(LineSegment.PointProperty,
|
||||
new PointAnimation(location.AsPoint(), animSpeed));
|
||||
Figure.Segments.Insert(atIndex, splitter.Left);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends the segment.
|
||||
/// </summary>
|
||||
/// <param name="atIndex">At index.</param>
|
||||
/// <param name="location">The location.</param>
|
||||
public virtual void EndSegment(int atIndex, CorePoint location)
|
||||
{
|
||||
var splitter = Splitters[ActiveSplitters-1];
|
||||
|
||||
var animSpeed = Model.Chart.View.AnimationsSpeed;
|
||||
var noAnim = Model.Chart.View.DisableAnimations;
|
||||
|
||||
var areaLimit = ChartFunctions.ToDrawMargin(double.IsNaN(AreaLimit)
|
||||
? Model.Chart.AxisY[ScalesYAt].FirstSeparator
|
||||
: AreaLimit, AxisOrientation.Y, Model.Chart, ScalesYAt);
|
||||
|
||||
var uw = Model.Chart.AxisX[ScalesXAt].EvaluatesUnitWidth
|
||||
? ChartFunctions.GetUnitWidth(AxisOrientation.X, Model.Chart, ScalesXAt)/2
|
||||
: 0;
|
||||
location.X -= uw;
|
||||
|
||||
if (splitter.IsNew)
|
||||
{
|
||||
splitter.Right.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
|
||||
}
|
||||
|
||||
Figure.Segments.Remove(splitter.Right);
|
||||
if (noAnim)
|
||||
splitter.Right.Point = new Point(location.X, areaLimit);
|
||||
else
|
||||
splitter.Right.BeginAnimation(LineSegment.PointProperty,
|
||||
new PointAnimation(new Point(location.X, areaLimit), animSpeed));
|
||||
Figure.Segments.Insert(atIndex, splitter.Right);
|
||||
|
||||
splitter.IsNew = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(LineSmoothnessProperty, .7d);
|
||||
SetCurrentValue(PointGeometrySizeProperty, 8d);
|
||||
SetCurrentValue(PointForegroundProperty, Brushes.White);
|
||||
SetCurrentValue(StrokeThicknessProperty, 2d);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.15;
|
||||
Splitters = new List<LineSegmentSplitter>();
|
||||
|
||||
IsNew = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp50</s:String></wpf:ResourceDictionary>
|
||||
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp50</s:String></wpf:ResourceDictionary>
|
||||
77
Others/Live-Charts-master/WpfView/LogarithmicAxis.cs
Normal file
77
Others/Live-Charts-master/WpfView/LogarithmicAxis.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
//copyright(c) 2016 Alberto Rodriguez
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// An Logarithmic Axis of a chart
|
||||
/// </summary>
|
||||
/// <seealso cref="LiveCharts.Wpf.Axis" />
|
||||
public class LogarithmicAxis : Axis, ILogarithmicAxisView
|
||||
{
|
||||
/// <summary>
|
||||
/// Ases the core element.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
public override AxisCore AsCoreElement(ChartCore chart, AxisOrientation source)
|
||||
{
|
||||
if(Model == null) Model = new LogarithmicAxisCore(this);
|
||||
|
||||
Model.ShowLabels = ShowLabels;
|
||||
Model.Chart = chart;
|
||||
Model.IsMerged = IsMerged;
|
||||
Model.Labels = Labels;
|
||||
Model.LabelFormatter = LabelFormatter;
|
||||
Model.MaxValue = MaxValue;
|
||||
Model.MinValue = MinValue;
|
||||
Model.Title = Title;
|
||||
Model.Position = Position;
|
||||
Model.Separator = Separator.AsCoreElement(Model, source);
|
||||
Model.DisableAnimations = DisableAnimations;
|
||||
Model.Sections = Sections.Select(x => x.AsCoreElement(Model, source)).ToList();
|
||||
|
||||
return Model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The base property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty BaseProperty = DependencyProperty.Register(
|
||||
"Base", typeof(double), typeof(LogarithmicAxis), new PropertyMetadata(10d, UpdateChart()));
|
||||
/// <summary>
|
||||
/// Gets or sets the base.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The base.
|
||||
/// </value>
|
||||
public double Base
|
||||
{
|
||||
get { return (double) GetValue(BaseProperty); }
|
||||
set { SetValue(BaseProperty, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
82
Others/Live-Charts-master/WpfView/Maps/MapResolver.cs
Normal file
82
Others/Live-Charts-master/WpfView/Maps/MapResolver.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using LiveCharts.Maps;
|
||||
|
||||
namespace LiveCharts.Wpf.Maps
|
||||
{
|
||||
internal static class MapResolver
|
||||
{
|
||||
public static LvcMap Get(string file)
|
||||
{
|
||||
//file = Path.Combine(Directory.GetCurrentDirectory(), file);
|
||||
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("File not found!");
|
||||
#endif
|
||||
#pragma warning disable 162
|
||||
// ReSharper disable once HeuristicUnreachableCode
|
||||
return null;
|
||||
#pragma warning restore 162
|
||||
}
|
||||
|
||||
var svgMap = new LvcMap
|
||||
{
|
||||
DesiredHeight = 600,
|
||||
DesiredWidth = 800,
|
||||
Data = new List<MapData>()
|
||||
};
|
||||
|
||||
using (var reader = XmlReader.Create(file, new XmlReaderSettings {IgnoreComments = true}))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.Name == "Height") svgMap.DesiredHeight = double.Parse(reader.ReadInnerXml());
|
||||
if (reader.Name == "Width") svgMap.DesiredWidth = double.Parse(reader.ReadInnerXml());
|
||||
if (reader.Name == "MapShape")
|
||||
{
|
||||
var p = new MapData
|
||||
{
|
||||
LvcMap = svgMap
|
||||
};
|
||||
reader.Read();
|
||||
while (reader.NodeType != XmlNodeType.EndElement)
|
||||
{
|
||||
if (reader.NodeType != XmlNodeType.Element) reader.Read();
|
||||
if (reader.Name == "Id") p.Id = reader.ReadInnerXml();
|
||||
if (reader.Name == "Name") p.Name = reader.ReadInnerXml();
|
||||
if (reader.Name == "Path") p.Data = reader.ReadInnerXml();
|
||||
}
|
||||
svgMap.Data.Add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return svgMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
244
Others/Live-Charts-master/WpfView/OhlcSeries.cs
Normal file
244
Others/Live-Charts-master/WpfView/OhlcSeries.cs
Normal file
@@ -0,0 +1,244 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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.SeriesAlgorithms;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
using LiveCharts.Wpf.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The OHCL series defines a financial series, add this series to a cartesian chart
|
||||
/// </summary>
|
||||
public class OhlcSeries : Series, IFinancialSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of OhclSeries class
|
||||
/// </summary>
|
||||
public OhlcSeries()
|
||||
{
|
||||
Model = new OhlcAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of OhclSeries class with a given mapper
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public OhlcSeries(object configuration)
|
||||
{
|
||||
Model = new OhlcAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The maximum column width property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxColumnWidthProperty = DependencyProperty.Register(
|
||||
"MaxColumnWidth", typeof (double), typeof (OhlcSeries), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum with of a point, a point will be capped to this width.
|
||||
/// </summary>
|
||||
public double MaxColumnWidth
|
||||
{
|
||||
get { return (double) GetValue(MaxColumnWidthProperty); }
|
||||
set { SetValue(MaxColumnWidthProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The increase brush property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IncreaseBrushProperty = DependencyProperty.Register(
|
||||
"IncreaseBrush", typeof (Brush), typeof (OhlcSeries), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the brush of the point when close value is grater than open value
|
||||
/// </summary>
|
||||
public Brush IncreaseBrush
|
||||
{
|
||||
get { return (Brush) GetValue(IncreaseBrushProperty); }
|
||||
set { SetValue(IncreaseBrushProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The decrease brush property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DecreaseBrushProperty = DependencyProperty.Register(
|
||||
"DecreaseBrush", typeof (Brush), typeof (OhlcSeries), new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the brush of the point when close value is less than open value
|
||||
/// </summary>
|
||||
public Brush DecreaseBrush
|
||||
{
|
||||
get { return (Brush) GetValue(DecreaseBrushProperty); }
|
||||
set { SetValue(DecreaseBrushProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// This method runs when the update starts
|
||||
/// </summary>
|
||||
public override void OnSeriesUpdateStart()
|
||||
{
|
||||
//do nothing on updateStart
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point view.
|
||||
/// </summary>
|
||||
/// <param name="point">The point.</param>
|
||||
/// <param name="label">The label.</param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (OhlcPointView)point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new OhlcPointView
|
||||
{
|
||||
IsNew = true,
|
||||
HighToLowLine = new Line(),
|
||||
OpenLine = new Line(),
|
||||
CloseLine = new Line()
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HighToLowLine);
|
||||
Model.Chart.View.AddToDrawMargin(pbv.OpenLine);
|
||||
Model.Chart.View.AddToDrawMargin(pbv.CloseLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HighToLowLine);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.OpenLine);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.CloseLine);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
pbv.HighToLowLine.StrokeThickness = StrokeThickness;
|
||||
pbv.CloseLine.StrokeThickness = StrokeThickness;
|
||||
pbv.OpenLine.StrokeThickness = StrokeThickness;
|
||||
|
||||
pbv.HighToLowLine.StrokeDashArray = StrokeDashArray;
|
||||
pbv.CloseLine.StrokeDashArray = StrokeDashArray;
|
||||
pbv.OpenLine.StrokeDashArray = StrokeDashArray;
|
||||
|
||||
pbv.HighToLowLine.Visibility = Visibility;
|
||||
pbv.CloseLine.Visibility = Visibility;
|
||||
pbv.OpenLine.Visibility = Visibility;
|
||||
|
||||
var i = Panel.GetZIndex(this);
|
||||
Panel.SetZIndex(pbv.HighToLowLine, i);
|
||||
Panel.SetZIndex(pbv.CloseLine, i);
|
||||
Panel.SetZIndex(pbv.OpenLine, i);
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
if (point.Open < point.Close)
|
||||
{
|
||||
pbv.HighToLowLine.Stroke = IncreaseBrush;
|
||||
pbv.CloseLine.Stroke = IncreaseBrush;
|
||||
pbv.OpenLine.Stroke = IncreaseBrush;
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.HighToLowLine.Stroke = DecreaseBrush;
|
||||
pbv.CloseLine.Stroke = DecreaseBrush;
|
||||
pbv.OpenLine.Stroke = DecreaseBrush;
|
||||
}
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(StrokeThicknessProperty, 2.5d);
|
||||
SetCurrentValue(MaxColumnWidthProperty, 35d);
|
||||
SetCurrentValue(MaxWidthProperty, 25d);
|
||||
SetCurrentValue(IncreaseBrushProperty, new SolidColorBrush(Color.FromRgb(76, 174, 80)));
|
||||
SetCurrentValue(DecreaseBrushProperty, new SolidColorBrush(Color.FromRgb(238, 83, 80)));
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x =>
|
||||
string.Format("O: {0}, H: {1}, L: {2} C: {3}", x.Open, x.High, x.Low, x.Close);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
116
Others/Live-Charts-master/WpfView/PieChart.cs
Normal file
116
Others/Live-Charts-master/WpfView/PieChart.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
using LiveCharts.Wpf.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The pie chart compares mainly the distribution of the data according to different series.
|
||||
/// </summary>
|
||||
public class PieChart : Chart, IPieChart
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of PieChart class
|
||||
/// </summary>
|
||||
public PieChart()
|
||||
{
|
||||
var freq = DisableAnimations ? TimeSpan.FromMilliseconds(10) : AnimationsSpeed;
|
||||
var updater = new Components.ChartUpdater(freq);
|
||||
ChartCoreModel = new PieChartCore(this, updater);
|
||||
|
||||
SetCurrentValue(SeriesProperty, new SeriesCollection());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The inner radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty InnerRadiusProperty = DependencyProperty.Register(
|
||||
"InnerRadius", typeof (double), typeof (PieChart), new PropertyMetadata(0d, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the pie inner radius, increasing this property will result in a doughnut chart.
|
||||
/// </summary>
|
||||
public double InnerRadius
|
||||
{
|
||||
get { return (double) GetValue(InnerRadiusProperty); }
|
||||
set { SetValue(InnerRadiusProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The starting rotation angle property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StartingRotationAngleProperty = DependencyProperty.Register(
|
||||
"StartingRotationAngle", typeof (double), typeof (PieChart), new PropertyMetadata(45d, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the starting rotation angle in degrees.
|
||||
/// </summary>
|
||||
public double StartingRotationAngle
|
||||
{
|
||||
get { return (double) GetValue(StartingRotationAngleProperty); }
|
||||
set { SetValue(StartingRotationAngleProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The hover push out property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HoverPushOutProperty = DependencyProperty.Register(
|
||||
"HoverPushOut", typeof (double), typeof (PieChart), new PropertyMetadata(5d));
|
||||
/// <summary>
|
||||
/// Gets or sets the units that a slice is pushed out when a user moves the mouse over data point.
|
||||
/// </summary>
|
||||
public double HoverPushOut
|
||||
{
|
||||
get { return (double) GetValue(HoverPushOutProperty); }
|
||||
set { SetValue(HoverPushOutProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tooltip position.
|
||||
/// </summary>
|
||||
/// <param name="senderPoint">The sender point.</param>
|
||||
/// <returns></returns>
|
||||
protected internal override Point GetTooltipPosition(ChartPoint senderPoint)
|
||||
{
|
||||
var pieSlice = ((PiePointView) senderPoint.View).Slice;
|
||||
|
||||
var alpha = pieSlice.RotationAngle + pieSlice.WedgeAngle * .5 + 180;
|
||||
var alphaRad = alpha * Math.PI / 180;
|
||||
var sliceMidAngle = alpha - 180;
|
||||
|
||||
DataTooltip.UpdateLayout();
|
||||
|
||||
var y = DrawMargin.ActualHeight*.5 +
|
||||
(sliceMidAngle > 90 && sliceMidAngle < 270 ? -1 : 0)*DataTooltip.ActualHeight -
|
||||
Math.Cos(alphaRad)*15;
|
||||
var x = DrawMargin.ActualWidth*.5 +
|
||||
(sliceMidAngle > 0 && sliceMidAngle < 180 ? -1 : 0)*DataTooltip.ActualWidth +
|
||||
Math.Sin(alphaRad)*15;
|
||||
|
||||
return new Point(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
194
Others/Live-Charts-master/WpfView/PieSeries.cs
Normal file
194
Others/Live-Charts-master/WpfView/PieSeries.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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 LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
using LiveCharts.Wpf.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The pie series should be added only in a pie chart.
|
||||
/// </summary>
|
||||
public class PieSeries : Series, IPieSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of PieSeries class
|
||||
/// </summary>
|
||||
public PieSeries()
|
||||
{
|
||||
Model = new PieAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of PieSeries class with a given mapper.
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public PieSeries(object configuration)
|
||||
{
|
||||
Model = new PieAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The push out property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PushOutProperty = DependencyProperty.Register(
|
||||
"PushOut", typeof (double), typeof (PieSeries), new PropertyMetadata(default(double), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the slice push out, this property highlights the slice
|
||||
/// </summary>
|
||||
public double PushOut
|
||||
{
|
||||
get { return (double) GetValue(PushOutProperty); }
|
||||
set { SetValue(PushOutProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The label position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelPositionProperty = DependencyProperty.Register(
|
||||
"LabelPosition", typeof(PieLabelPosition), typeof(PieSeries),
|
||||
new PropertyMetadata(PieLabelPosition.InsideSlice, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the label position.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The label position.
|
||||
/// </value>
|
||||
public PieLabelPosition LabelPosition
|
||||
{
|
||||
get { return (PieLabelPosition) GetValue(LabelPositionProperty); }
|
||||
set { SetValue(LabelPositionProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (PiePointView) point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new PiePointView
|
||||
{
|
||||
IsNew = true,
|
||||
Slice = new PieSlice()
|
||||
};
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Slice);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Slice);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
pbv.Slice.Fill = Fill;
|
||||
pbv.Slice.Stroke = Stroke;
|
||||
pbv.Slice.StrokeThickness = StrokeThickness;
|
||||
pbv.Slice.StrokeDashArray = StrokeDashArray;
|
||||
pbv.Slice.PushOut = PushOut;
|
||||
pbv.Slice.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.Slice, Panel.GetZIndex(this));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new PieSlice
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
pbv.OriginalPushOut = PushOut;
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(StrokeThicknessProperty, 2d);
|
||||
SetCurrentValue(StrokeProperty, Brushes.White);
|
||||
SetCurrentValue(ForegroundProperty, Brushes.White);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
199
Others/Live-Charts-master/WpfView/Points/CandlePointView.cs
Normal file
199
Others/Live-Charts-master/WpfView/Points/CandlePointView.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class CandlePointView : PointView, IOhlcPointView
|
||||
{
|
||||
public Line HighToLowLine { get; set; }
|
||||
public Rectangle OpenToCloseRectangle { get; set; }
|
||||
public double Open { get; set; }
|
||||
public double High { get; set; }
|
||||
public double Close { get; set; }
|
||||
public double Low { get; set; }
|
||||
public double Width { get; set; }
|
||||
public double Left { get; set; }
|
||||
public double StartReference { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
var center = Left + Width / 2;
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
HighToLowLine.X1 = center;
|
||||
HighToLowLine.X2 = center;
|
||||
HighToLowLine.Y1 = StartReference;
|
||||
HighToLowLine.Y2 = StartReference;
|
||||
|
||||
Canvas.SetTop(OpenToCloseRectangle, (Open + Close) / 2);
|
||||
Canvas.SetLeft(OpenToCloseRectangle, Left);
|
||||
|
||||
OpenToCloseRectangle.Width = Width;
|
||||
OpenToCloseRectangle.Height = 0;
|
||||
}
|
||||
|
||||
if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, current.ChartLocation.Y);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X);
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
var h = Math.Abs(High - Low);
|
||||
HoverShape.Width = Width;
|
||||
HoverShape.Height = h > 10 ? h : 10;
|
||||
Canvas.SetLeft(HoverShape, Left);
|
||||
Canvas.SetTop(HoverShape, High);
|
||||
}
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
HighToLowLine.Y1 = High;
|
||||
HighToLowLine.Y2 = Low;
|
||||
HighToLowLine.X1 = center;
|
||||
HighToLowLine.X2 = center;
|
||||
|
||||
OpenToCloseRectangle.Width = Width;
|
||||
OpenToCloseRectangle.Height = Math.Abs(Open - Close);
|
||||
|
||||
Canvas.SetTop(OpenToCloseRectangle, Math.Min(Open, Close));
|
||||
Canvas.SetLeft(OpenToCloseRectangle, Left);
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualHeight * .5, chart);
|
||||
var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualWidth * .5, chart);
|
||||
|
||||
Canvas.SetTop(DataLabel, cy);
|
||||
Canvas.SetLeft(DataLabel, cx);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var candleSeries = (CandleSeries) current.SeriesView;
|
||||
|
||||
if (candleSeries.ColoringRules == null)
|
||||
{
|
||||
if (current.Open <= current.Close)
|
||||
{
|
||||
HighToLowLine.Stroke = candleSeries.IncreaseBrush;
|
||||
OpenToCloseRectangle.Fill = candleSeries.IncreaseBrush;
|
||||
OpenToCloseRectangle.Stroke = candleSeries.IncreaseBrush;
|
||||
}
|
||||
else
|
||||
{
|
||||
HighToLowLine.Stroke = candleSeries.DecreaseBrush;
|
||||
OpenToCloseRectangle.Fill = candleSeries.DecreaseBrush;
|
||||
OpenToCloseRectangle.Stroke = candleSeries.DecreaseBrush;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var rule in candleSeries.ColoringRules)
|
||||
{
|
||||
if (!rule.Condition(current, previousDrawn)) continue;
|
||||
|
||||
HighToLowLine.Stroke = rule.Stroke;
|
||||
OpenToCloseRectangle.Fill = rule.Fill;
|
||||
OpenToCloseRectangle.Stroke = rule.Stroke;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart);
|
||||
var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart);
|
||||
|
||||
DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(cx, animSpeed));
|
||||
DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(cy, animSpeed));
|
||||
}
|
||||
|
||||
HighToLowLine.BeginAnimation(Line.X1Property, new DoubleAnimation(center, animSpeed));
|
||||
HighToLowLine.BeginAnimation(Line.X2Property, new DoubleAnimation(center, animSpeed));
|
||||
HighToLowLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(High, animSpeed));
|
||||
HighToLowLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Low, animSpeed));
|
||||
|
||||
OpenToCloseRectangle.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(Left, animSpeed));
|
||||
OpenToCloseRectangle.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(Math.Min(Open, Close), animSpeed));
|
||||
|
||||
OpenToCloseRectangle.BeginAnimation(FrameworkElement.WidthProperty,
|
||||
new DoubleAnimation(Width, animSpeed));
|
||||
OpenToCloseRectangle.BeginAnimation(FrameworkElement.HeightProperty,
|
||||
new DoubleAnimation(Math.Max(Math.Abs(Open - Close), OpenToCloseRectangle.StrokeThickness), animSpeed));
|
||||
|
||||
}
|
||||
|
||||
public override void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(HoverShape);
|
||||
chart.View.RemoveFromDrawMargin(OpenToCloseRectangle);
|
||||
chart.View.RemoveFromDrawMargin(HighToLowLine);
|
||||
chart.View.RemoveFromDrawMargin(DataLabel);
|
||||
}
|
||||
|
||||
protected double CorrectXLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
if (desiredPosition + DataLabel.ActualWidth * .5 < -0.1) return -DataLabel.ActualWidth;
|
||||
|
||||
if (desiredPosition + DataLabel.ActualWidth > chart.DrawMargin.Width)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualWidth - chart.DrawMargin.Width + 2;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
|
||||
protected double CorrectYLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
//desiredPosition -= Ellipse.ActualHeight * .5 + DataLabel.ActualHeight * .5 + 2;
|
||||
|
||||
if (desiredPosition + DataLabel.ActualHeight > chart.DrawMargin.Height)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualHeight - chart.DrawMargin.Height + 2;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
205
Others/Live-Charts-master/WpfView/Points/ColumnPointView.cs
Normal file
205
Others/Live-Charts-master/WpfView/Points/ColumnPointView.cs
Normal file
@@ -0,0 +1,205 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class ColumnPointView : PointView, IRectanglePointView
|
||||
{
|
||||
public Rectangle Rectangle { get; set; }
|
||||
public CoreRectangle Data { get; set; }
|
||||
public double ZeroReference { get; set; }
|
||||
public BarLabelPosition LabelPosition { get; set; }
|
||||
private RotateTransform Transform { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
if (IsNew)
|
||||
{
|
||||
Canvas.SetTop(Rectangle, ZeroReference);
|
||||
Canvas.SetLeft(Rectangle, Data.Left);
|
||||
|
||||
Rectangle.Width = Data.Width;
|
||||
Rectangle.Height = 0;
|
||||
}
|
||||
|
||||
if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, ZeroReference);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X);
|
||||
}
|
||||
|
||||
Func<double> getY = () =>
|
||||
{
|
||||
double y;
|
||||
|
||||
#pragma warning disable 618
|
||||
if (LabelPosition == BarLabelPosition.Parallel || LabelPosition == BarLabelPosition.Merged)
|
||||
#pragma warning restore 618
|
||||
{
|
||||
if (Transform == null)
|
||||
Transform = new RotateTransform(270);
|
||||
|
||||
y = Data.Top + Data.Height/2 + DataLabel.ActualWidth*.5;
|
||||
DataLabel.RenderTransform = Transform;
|
||||
}
|
||||
else if (LabelPosition == BarLabelPosition.Perpendicular)
|
||||
{
|
||||
y = Data.Top + Data.Height/2 - DataLabel.ActualHeight * .5;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ZeroReference > Data.Top)
|
||||
{
|
||||
y = Data.Top - DataLabel.ActualHeight;
|
||||
if (y < 0) y = Data.Top;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = Data.Top + Data.Height;
|
||||
if (y + DataLabel.ActualHeight > chart.DrawMargin.Height) y -= DataLabel.ActualHeight;
|
||||
}
|
||||
}
|
||||
|
||||
return y;
|
||||
};
|
||||
|
||||
Func<double> getX = () =>
|
||||
{
|
||||
double x;
|
||||
|
||||
#pragma warning disable 618
|
||||
if (LabelPosition == BarLabelPosition.Parallel || LabelPosition == BarLabelPosition.Merged)
|
||||
#pragma warning restore 618
|
||||
{
|
||||
x = Data.Left + Data.Width/2 - DataLabel.ActualHeight/2;
|
||||
}
|
||||
else if (LabelPosition == BarLabelPosition.Perpendicular)
|
||||
{
|
||||
x = Data.Left + Data.Width/2 - DataLabel.ActualWidth/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = Data.Left + Data.Width / 2 - DataLabel.ActualWidth / 2;
|
||||
if (x < 0)
|
||||
x = 2;
|
||||
if (x + DataLabel.ActualWidth > chart.DrawMargin.Width)
|
||||
x -= x + DataLabel.ActualWidth - chart.DrawMargin.Width + 2;
|
||||
}
|
||||
|
||||
return x;
|
||||
};
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
Rectangle.Width = Data.Width;
|
||||
Rectangle.Height = Data.Height;
|
||||
|
||||
Canvas.SetTop(Rectangle, Data.Top);
|
||||
Canvas.SetLeft(Rectangle, Data.Left);
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
Canvas.SetTop(DataLabel, getY());
|
||||
Canvas.SetLeft(DataLabel, getX());
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
Canvas.SetTop(HoverShape, Data.Top);
|
||||
Canvas.SetLeft(HoverShape, Data.Left);
|
||||
HoverShape.Height = Data.Height;
|
||||
HoverShape.Width = Data.Width;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(getX(), animSpeed));
|
||||
DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(getY(), animSpeed));
|
||||
}
|
||||
|
||||
Rectangle.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(Data.Left, animSpeed));
|
||||
Rectangle.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(Data.Top, animSpeed));
|
||||
|
||||
Rectangle.BeginAnimation(FrameworkElement.WidthProperty,
|
||||
new DoubleAnimation(Data.Width, animSpeed));
|
||||
Rectangle.BeginAnimation(FrameworkElement.HeightProperty,
|
||||
new DoubleAnimation(Data.Height, animSpeed));
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
Canvas.SetTop(HoverShape, Data.Top);
|
||||
Canvas.SetLeft(HoverShape, Data.Left);
|
||||
HoverShape.Height = Data.Height;
|
||||
HoverShape.Width = Data.Width;
|
||||
}
|
||||
}
|
||||
|
||||
public override void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(HoverShape);
|
||||
chart.View.RemoveFromDrawMargin(Rectangle);
|
||||
chart.View.RemoveFromDrawMargin(DataLabel);
|
||||
}
|
||||
|
||||
public override void OnHover(ChartPoint point)
|
||||
{
|
||||
var copy = Rectangle.Fill.Clone();
|
||||
copy.Opacity -= .15;
|
||||
Rectangle.Fill = copy;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
if (Rectangle == null) return;
|
||||
|
||||
if (point.Fill != null)
|
||||
{
|
||||
Rectangle.Fill = (Brush) point.Fill;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle.Fill = ((Series) point.SeriesView).Fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
105
Others/Live-Charts-master/WpfView/Points/HeatPoint.cs
Normal file
105
Others/Live-Charts-master/WpfView/Points/HeatPoint.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class HeatPoint : PointView, IHeatPointView
|
||||
{
|
||||
public Rectangle Rectangle { get; set; }
|
||||
public CoreColor ColorComponents { get; set; }
|
||||
public double Width { get; set; }
|
||||
public double Height { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
Canvas.SetTop(Rectangle, current.ChartLocation.Y);
|
||||
Canvas.SetLeft(Rectangle, current.ChartLocation.X);
|
||||
|
||||
Rectangle.Width = Width;
|
||||
Rectangle.Height = Height;
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
Rectangle.Fill = new SolidColorBrush(Colors.Transparent);
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
HoverShape.Width = Width;
|
||||
HoverShape.Height = Height;
|
||||
Canvas.SetLeft(HoverShape, current.ChartLocation.X);
|
||||
Canvas.SetTop(HoverShape, current.ChartLocation.Y);
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
Canvas.SetTop(DataLabel, current.ChartLocation.Y + (Height/2) - DataLabel.ActualHeight*.5);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X + (Width/2) - DataLabel.ActualWidth*.5);
|
||||
}
|
||||
|
||||
var targetColor = new Color
|
||||
{
|
||||
A = ColorComponents.A,
|
||||
R = ColorComponents.R,
|
||||
G = ColorComponents.G,
|
||||
B = ColorComponents.B
|
||||
};
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
Rectangle.Fill = new SolidColorBrush(targetColor);
|
||||
return;
|
||||
}
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
Rectangle.Fill.BeginAnimation(SolidColorBrush.ColorProperty,
|
||||
new ColorAnimation(targetColor, animSpeed));
|
||||
}
|
||||
|
||||
public override void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(HoverShape);
|
||||
chart.View.RemoveFromDrawMargin(Rectangle);
|
||||
chart.View.RemoveFromDrawMargin(DataLabel);
|
||||
}
|
||||
|
||||
public override void OnHover(ChartPoint point)
|
||||
{
|
||||
Rectangle.StrokeThickness++;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
Rectangle.StrokeThickness = ((Series) point.SeriesView).StrokeThickness;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class HorizontalBezierPointView : PointView, IBezierPointView
|
||||
{
|
||||
public BezierSegment Segment { get; set; }
|
||||
public Path Shape { get; set; }
|
||||
public PathFigure Container { get; set; }
|
||||
public BezierData Data { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
var previosPbv = previousDrawn == null
|
||||
? null
|
||||
: (HorizontalBezierPointView) previousDrawn.View;
|
||||
|
||||
var y = chart.DrawMargin.Top + chart.DrawMargin.Height;
|
||||
|
||||
Container.Segments.Remove(Segment);
|
||||
Container.Segments.Insert(index, Segment);
|
||||
|
||||
ValidArea = new CoreRectangle(current.ChartLocation.X - 7.5, current.ChartLocation.Y - 7.5, 15, 15);
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
if (previosPbv != null && !previosPbv.IsNew)
|
||||
{
|
||||
Segment.Point1 = previosPbv.Segment.Point3;
|
||||
Segment.Point2 = previosPbv.Segment.Point3;
|
||||
Segment.Point3 = previosPbv.Segment.Point3;
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetTop(Shape, Canvas.GetTop(previosPbv.Shape));
|
||||
Canvas.SetLeft(Shape, Canvas.GetLeft(previosPbv.Shape));
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
Canvas.SetTop(DataLabel, Canvas.GetTop(previosPbv.DataLabel));
|
||||
Canvas.SetLeft(DataLabel, Canvas.GetLeft(previosPbv.DataLabel));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (current.SeriesView.IsFirstDraw)
|
||||
{
|
||||
Segment.Point1 = new Point(Data.Point1.X, y);
|
||||
Segment.Point2 = new Point(Data.Point2.X, y);
|
||||
Segment.Point3 = new Point(Data.Point3.X, y);
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetTop(Shape, y);
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width*.5);
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
Canvas.SetTop(DataLabel, y);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X - DataLabel.ActualWidth * .5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var startPoint = ((LineSeries)current.SeriesView).Splitters[0].Left.Point;
|
||||
Segment.Point1 = startPoint;
|
||||
Segment.Point2 = startPoint;
|
||||
Segment.Point3 = startPoint;
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetTop(Shape, y);
|
||||
Canvas.SetLeft(Shape, startPoint.X - Shape.Width * .5);
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
Canvas.SetTop(DataLabel, y);
|
||||
Canvas.SetLeft(DataLabel, startPoint.X - DataLabel.ActualWidth * .5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, y);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X - DataLabel.ActualWidth*.5);
|
||||
}
|
||||
|
||||
#region No Animated
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
Segment.Point1 = Data.Point1.AsPoint();
|
||||
Segment.Point2 = Data.Point2.AsPoint();
|
||||
Segment.Point3 = Data.Point3.AsPoint();
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width*.5);
|
||||
Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height*.5);
|
||||
}
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width*.5);
|
||||
Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height*.5);
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart);
|
||||
var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart);
|
||||
Canvas.SetLeft(DataLabel, xl);
|
||||
Canvas.SetTop(DataLabel, yl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Segment.BeginAnimation(BezierSegment.Point1Property,
|
||||
new PointAnimation(Segment.Point1, Data.Point1.AsPoint(), chart.View.AnimationsSpeed));
|
||||
Segment.BeginAnimation(BezierSegment.Point2Property,
|
||||
new PointAnimation(Segment.Point2, Data.Point2.AsPoint(), chart.View.AnimationsSpeed));
|
||||
Segment.BeginAnimation(BezierSegment.Point3Property,
|
||||
new PointAnimation(Segment.Point3, Data.Point3.AsPoint(), chart.View.AnimationsSpeed));
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
if (double.IsNaN(Canvas.GetLeft(Shape)))
|
||||
{
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5);
|
||||
Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5);
|
||||
}
|
||||
else
|
||||
{
|
||||
Shape.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(current.ChartLocation.X - Shape.Width*.5, chart.View.AnimationsSpeed));
|
||||
Shape.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(current.ChartLocation.Y - Shape.Height * .5, chart.View.AnimationsSpeed));
|
||||
}
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth*.5, chart);
|
||||
var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight*.5, chart);
|
||||
|
||||
DataLabel.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(xl, chart.View.AnimationsSpeed));
|
||||
DataLabel.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(yl, chart.View.AnimationsSpeed));
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width*.5);
|
||||
Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height*.5);
|
||||
}
|
||||
}
|
||||
|
||||
public override void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(HoverShape);
|
||||
chart.View.RemoveFromDrawMargin(Shape);
|
||||
chart.View.RemoveFromDrawMargin(DataLabel);
|
||||
Container.Segments.Remove(Segment);
|
||||
}
|
||||
|
||||
protected double CorrectXLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
if (desiredPosition + DataLabel.ActualWidth*.5 < -0.1) return -DataLabel.ActualWidth;
|
||||
|
||||
if (desiredPosition + DataLabel.ActualWidth > chart.DrawMargin.Width)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualWidth - chart.DrawMargin.Width + 2;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
|
||||
protected double CorrectYLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
desiredPosition -= (Shape == null ? 0 : Shape.ActualHeight*.5) + DataLabel.ActualHeight*.5 + 2;
|
||||
|
||||
if (desiredPosition + DataLabel.ActualHeight > chart.DrawMargin.Height)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualHeight - chart.DrawMargin.Height + 2;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
|
||||
public override void OnHover(ChartPoint point)
|
||||
{
|
||||
var lineSeries = (LineSeries)point.SeriesView;
|
||||
if (Shape != null) Shape.Fill = Shape.Stroke;
|
||||
lineSeries.Path.StrokeThickness = lineSeries.StrokeThickness + 1;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
var lineSeries = (LineSeries) point.SeriesView;
|
||||
if (Shape != null)
|
||||
Shape.Fill = point.Fill == null
|
||||
? lineSeries.PointForeground
|
||||
: (Brush) point.Fill;
|
||||
lineSeries.Path.StrokeThickness = lineSeries.StrokeThickness;
|
||||
}
|
||||
}
|
||||
}
|
||||
179
Others/Live-Charts-master/WpfView/Points/OhlcPointView.cs
Normal file
179
Others/Live-Charts-master/WpfView/Points/OhlcPointView.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class OhlcPointView : PointView, IOhlcPointView
|
||||
{
|
||||
public Line HighToLowLine { get; set; }
|
||||
public Line OpenLine { get; set; }
|
||||
public Line CloseLine { get; set; }
|
||||
public double Open { get; set; }
|
||||
public double High { get; set; }
|
||||
public double Close { get; set; }
|
||||
public double Low { get; set; }
|
||||
public double Width { get; set; }
|
||||
public double Left { get; set; }
|
||||
public double StartReference { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
var center = Left + Width / 2;
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
HighToLowLine.X1 = center;
|
||||
HighToLowLine.X2 = center;
|
||||
HighToLowLine.Y1 = StartReference;
|
||||
HighToLowLine.Y2 = StartReference;
|
||||
|
||||
OpenLine.X1 = Left;
|
||||
OpenLine.X2 = center;
|
||||
OpenLine.Y1 = StartReference;
|
||||
OpenLine.Y2 = StartReference;
|
||||
|
||||
CloseLine.X1 = center;
|
||||
CloseLine.X2 = Left + Width;
|
||||
CloseLine.Y1 = StartReference;
|
||||
CloseLine.Y2 = StartReference;
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
Canvas.SetTop(DataLabel, current.ChartLocation.Y);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X);
|
||||
}
|
||||
}
|
||||
|
||||
if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, current.ChartLocation.Y);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X);
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
var h = Math.Abs(High - Low);
|
||||
HoverShape.Width = Width;
|
||||
HoverShape.Height = h > 10 ? h : 10;
|
||||
Canvas.SetLeft(HoverShape, Left);
|
||||
Canvas.SetTop(HoverShape, High);
|
||||
}
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
HighToLowLine.Y1 = High;
|
||||
HighToLowLine.Y2 = Low;
|
||||
HighToLowLine.X1 = center;
|
||||
HighToLowLine.X2 = center;
|
||||
|
||||
OpenLine.Y1 = Open;
|
||||
OpenLine.Y2 = Open;
|
||||
OpenLine.X1 = Left;
|
||||
OpenLine.X2 = center;
|
||||
|
||||
CloseLine.Y1 = Close;
|
||||
CloseLine.Y2 = Close;
|
||||
CloseLine.X1 = center;
|
||||
CloseLine.X2 = Left;
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualHeight*.5, chart);
|
||||
var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualWidth*.5, chart);
|
||||
|
||||
Canvas.SetTop(DataLabel, cy);
|
||||
Canvas.SetLeft(DataLabel, cx);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth*.5, chart);
|
||||
var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight*.5, chart);
|
||||
|
||||
DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(cx, animSpeed));
|
||||
DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(cy, animSpeed));
|
||||
}
|
||||
|
||||
HighToLowLine.BeginAnimation(Line.X1Property, new DoubleAnimation(center, animSpeed));
|
||||
HighToLowLine.BeginAnimation(Line.X2Property, new DoubleAnimation(center, animSpeed));
|
||||
OpenLine.BeginAnimation(Line.X1Property, new DoubleAnimation(Left, animSpeed));
|
||||
OpenLine.BeginAnimation(Line.X2Property, new DoubleAnimation(center, animSpeed));
|
||||
CloseLine.BeginAnimation(Line.X1Property, new DoubleAnimation(center, animSpeed));
|
||||
CloseLine.BeginAnimation(Line.X2Property, new DoubleAnimation(Left + Width, animSpeed));
|
||||
|
||||
HighToLowLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(High, animSpeed));
|
||||
HighToLowLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Low, animSpeed));
|
||||
OpenLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(Open, animSpeed));
|
||||
OpenLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Open, animSpeed));
|
||||
CloseLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(Close, animSpeed));
|
||||
CloseLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(Close, animSpeed));
|
||||
}
|
||||
|
||||
public override void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(HoverShape);
|
||||
chart.View.RemoveFromDrawMargin(OpenLine);
|
||||
chart.View.RemoveFromDrawMargin(CloseLine);
|
||||
chart.View.RemoveFromDrawMargin(HighToLowLine);
|
||||
chart.View.RemoveFromDrawMargin(DataLabel);
|
||||
}
|
||||
|
||||
protected double CorrectXLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
if (desiredPosition + DataLabel.ActualWidth * .5 < -0.1) return -DataLabel.ActualWidth;
|
||||
|
||||
if (desiredPosition + DataLabel.ActualWidth > chart.DrawMargin.Width)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualWidth - chart.DrawMargin.Width + 2;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
|
||||
protected double CorrectYLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
if (desiredPosition + DataLabel.ActualHeight > chart.DrawMargin.Height)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualHeight - chart.DrawMargin.Height + 2;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
162
Others/Live-Charts-master/WpfView/Points/PiePointView.cs
Normal file
162
Others/Live-Charts-master/WpfView/Points/PiePointView.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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.Media.Animation;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class PiePointView : PointView, IPieSlicePointView
|
||||
{
|
||||
public double Rotation { get; set; }
|
||||
public double InnerRadius { get; set; }
|
||||
public double Radius { get; set; }
|
||||
public double Wedge { get; set; }
|
||||
public PieSlice Slice { get; set; }
|
||||
public double OriginalPushOut { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
if (IsNew)
|
||||
{
|
||||
Canvas.SetTop(Slice, chart.DrawMargin.Height/2);
|
||||
Canvas.SetLeft(Slice, chart.DrawMargin.Width/2);
|
||||
|
||||
Slice.WedgeAngle = 0;
|
||||
Slice.RotationAngle = 0;
|
||||
}
|
||||
|
||||
if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, chart.DrawMargin.Height/2);
|
||||
Canvas.SetLeft(DataLabel, chart.DrawMargin.Width/2);
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
var hs = (PieSlice) HoverShape;
|
||||
|
||||
Canvas.SetTop(hs, chart.DrawMargin.Height/2);
|
||||
Canvas.SetLeft(hs, chart.DrawMargin.Width/2);
|
||||
hs.WedgeAngle = Wedge;
|
||||
hs.RotationAngle = Rotation;
|
||||
hs.InnerRadius = InnerRadius;
|
||||
hs.Radius = Radius;
|
||||
}
|
||||
|
||||
var lh = 0d;
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
lh = DataLabel.ActualHeight;
|
||||
}
|
||||
|
||||
var hypo = ((PieSeries) current.SeriesView).LabelPosition == PieLabelPosition.InsideSlice
|
||||
? (Radius + InnerRadius)*(Math.Abs(InnerRadius) < 0.01 ? .65 : .5)
|
||||
: Radius+lh;
|
||||
var gamma = current.Participation*360/2 + Rotation;
|
||||
var cp = new Point(hypo * Math.Sin(gamma * (Math.PI / 180)), hypo * Math.Cos(gamma * (Math.PI / 180)));
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
Slice.InnerRadius = InnerRadius;
|
||||
Slice.Radius = Radius;
|
||||
Slice.WedgeAngle = Wedge;
|
||||
Slice.RotationAngle = Rotation;
|
||||
Canvas.SetTop(Slice, chart.DrawMargin.Height / 2);
|
||||
Canvas.SetLeft(Slice, chart.DrawMargin.Width / 2);
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
var lx = cp.X + chart.DrawMargin.Width/2 - DataLabel.ActualWidth * .5;
|
||||
var ly = chart.DrawMargin.Height/2 - cp.Y - DataLabel.ActualHeight*.5;
|
||||
|
||||
Canvas.SetLeft(DataLabel, lx);
|
||||
Canvas.SetTop(DataLabel, ly);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
var lx = cp.X + chart.DrawMargin.Width/2 - DataLabel.ActualWidth * .5;
|
||||
var ly = chart.DrawMargin.Height/2 - cp.Y - DataLabel.ActualHeight * .5;
|
||||
|
||||
DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(lx, animSpeed));
|
||||
DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(ly, animSpeed));
|
||||
}
|
||||
|
||||
Slice.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(chart.DrawMargin.Width / 2, animSpeed));
|
||||
Slice.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(chart.DrawMargin.Height/2, animSpeed));
|
||||
Slice.BeginAnimation(PieSlice.InnerRadiusProperty, new DoubleAnimation(InnerRadius, animSpeed));
|
||||
Slice.BeginAnimation(PieSlice.RadiusProperty, new DoubleAnimation(Radius, animSpeed));
|
||||
Slice.BeginAnimation(PieSlice.WedgeAngleProperty, new DoubleAnimation(Wedge, animSpeed));
|
||||
Slice.BeginAnimation(PieSlice.RotationAngleProperty, new DoubleAnimation(Rotation, animSpeed));
|
||||
}
|
||||
|
||||
public override void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(HoverShape);
|
||||
chart.View.RemoveFromDrawMargin(Slice);
|
||||
chart.View.RemoveFromDrawMargin(DataLabel);
|
||||
}
|
||||
|
||||
public override void OnHover(ChartPoint point)
|
||||
{
|
||||
var copy = Slice.Fill.Clone();
|
||||
copy.Opacity -= .15;
|
||||
Slice.Fill = copy;
|
||||
|
||||
var pieChart = (PieChart) point.SeriesView.Model.Chart.View;
|
||||
|
||||
Slice.BeginAnimation(PieSlice.PushOutProperty,
|
||||
new DoubleAnimation(Slice.PushOut, OriginalPushOut + pieChart.HoverPushOut,
|
||||
point.SeriesView.Model.Chart.View.AnimationsSpeed));
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
if (point.Fill != null)
|
||||
{
|
||||
Slice.Fill = (Brush)point.Fill;
|
||||
}
|
||||
else
|
||||
{
|
||||
Slice.Fill = ((Series) point.SeriesView).Fill;
|
||||
}
|
||||
Slice.BeginAnimation(PieSlice.PushOutProperty,
|
||||
new DoubleAnimation(OriginalPushOut, point.SeriesView.Model.Chart.View.AnimationsSpeed));
|
||||
}
|
||||
}
|
||||
}
|
||||
266
Others/Live-Charts-master/WpfView/Points/PieSlice.cs
Normal file
266
Others/Live-Charts-master/WpfView/Points/PieSlice.cs
Normal file
@@ -0,0 +1,266 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
//special thanks to Colin Eberhardt for the article.
|
||||
//http://www.codeproject.com/Articles/28098/A-WPF-Pie-Chart-with-Data-Binding-Support
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Shapes.Shape" />
|
||||
public class PieSlice : Shape
|
||||
{
|
||||
#region dependency properties
|
||||
|
||||
/// <summary>
|
||||
/// The radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RadiusProperty =
|
||||
DependencyProperty.Register("RadiusProperty", typeof(double), typeof(PieSlice),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The radius of this pie piece
|
||||
/// </summary>
|
||||
public double Radius
|
||||
{
|
||||
get { return (double)GetValue(RadiusProperty); }
|
||||
set { SetValue(RadiusProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The push out property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PushOutProperty =
|
||||
DependencyProperty.Register("PushOutProperty", typeof(double), typeof(PieSlice),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The distance to 'push' this pie piece out from the centre.
|
||||
/// </summary>
|
||||
public double PushOut
|
||||
{
|
||||
get { return (double)GetValue(PushOutProperty); }
|
||||
set { SetValue(PushOutProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The inner radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty InnerRadiusProperty =
|
||||
DependencyProperty.Register("InnerRadiusProperty", typeof(double), typeof(PieSlice),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
/// <summary>
|
||||
/// The inner radius of this pie piece
|
||||
/// </summary>
|
||||
public double InnerRadius
|
||||
{
|
||||
get { return (double)GetValue(InnerRadiusProperty); }
|
||||
set { SetValue(InnerRadiusProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The wedge angle property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty WedgeAngleProperty =
|
||||
DependencyProperty.Register("WedgeAngleProperty", typeof(double), typeof(PieSlice),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The wedge angle of this pie piece in degrees
|
||||
/// </summary>
|
||||
public double WedgeAngle
|
||||
{
|
||||
get { return (double)GetValue(WedgeAngleProperty); }
|
||||
set
|
||||
{
|
||||
SetValue(WedgeAngleProperty, value);
|
||||
Percentage = (value / 360.0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The rotation angle property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RotationAngleProperty =
|
||||
DependencyProperty.Register("RotationAngleProperty", typeof(double), typeof(PieSlice),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The rotation, in degrees, from the Y axis vector of this pie piece.
|
||||
/// </summary>
|
||||
public double RotationAngle
|
||||
{
|
||||
get { return (double)GetValue(RotationAngleProperty); }
|
||||
set { SetValue(RotationAngleProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The centre x property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty CentreXProperty =
|
||||
DependencyProperty.Register("CentreXProperty", typeof(double), typeof(PieSlice),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The X coordinate of centre of the circle from which this pie piece is cut.
|
||||
/// </summary>
|
||||
public double CentreX
|
||||
{
|
||||
get { return (double)GetValue(CentreXProperty); }
|
||||
set { SetValue(CentreXProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The centre y property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty CentreYProperty =
|
||||
DependencyProperty.Register("CentreYProperty", typeof(double), typeof(PieSlice),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The Y coordinate of centre of the circle from which this pie piece is cut.
|
||||
/// </summary>
|
||||
public double CentreY
|
||||
{
|
||||
get { return (double)GetValue(CentreYProperty); }
|
||||
set { SetValue(CentreYProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The percentage property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PercentageProperty =
|
||||
DependencyProperty.Register("PercentageProperty", typeof(double), typeof(PieSlice),
|
||||
new FrameworkPropertyMetadata(0.0));
|
||||
|
||||
/// <summary>
|
||||
/// The percentage of a full pie that this piece occupies.
|
||||
/// </summary>
|
||||
public double Percentage
|
||||
{
|
||||
get { return (double)GetValue(PercentageProperty); }
|
||||
private set { SetValue(PercentageProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The piece value property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PieceValueProperty =
|
||||
DependencyProperty.Register("PieceValueProperty", typeof(double), typeof(PieSlice),
|
||||
new FrameworkPropertyMetadata(0.0));
|
||||
|
||||
/// <summary>
|
||||
/// The value that this pie piece represents.
|
||||
/// </summary>
|
||||
public double PieceValue
|
||||
{
|
||||
get { return (double)GetValue(PieceValueProperty); }
|
||||
set { SetValue(PieceValueProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value that represents the <see cref="T:System.Windows.Media.Geometry" /> of the <see cref="T:System.Windows.Shapes.Shape" />.
|
||||
/// </summary>
|
||||
protected override Geometry DefiningGeometry
|
||||
{
|
||||
get
|
||||
{
|
||||
// Create a StreamGeometry for describing the shape
|
||||
var geometry = new StreamGeometry { FillRule = FillRule.EvenOdd };
|
||||
|
||||
using (var context = geometry.Open())
|
||||
{
|
||||
DrawGeometry(context);
|
||||
}
|
||||
|
||||
// Freeze the geometry for performance benefits
|
||||
geometry.Freeze();
|
||||
|
||||
return geometry;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the pie piece
|
||||
/// </summary>
|
||||
private void DrawGeometry(StreamGeometryContext context)
|
||||
{
|
||||
var innerArcStartPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle, InnerRadius);
|
||||
innerArcStartPoint.Offset(CentreX, CentreY);
|
||||
var innerArcEndPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius);
|
||||
innerArcEndPoint.Offset(CentreX, CentreY);
|
||||
var outerArcStartPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle, Radius);
|
||||
outerArcStartPoint.Offset(CentreX, CentreY);
|
||||
var outerArcEndPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius);
|
||||
outerArcEndPoint.Offset(CentreX, CentreY);
|
||||
var innerArcMidPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle * .5, InnerRadius);
|
||||
innerArcMidPoint.Offset(CentreX, CentreY);
|
||||
var outerArcMidPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle * .5, Radius);
|
||||
outerArcMidPoint.Offset(CentreX, CentreY);
|
||||
|
||||
var largeArc = WedgeAngle > 180.0d;
|
||||
var requiresMidPoint = Math.Abs(WedgeAngle - 360) < .01;
|
||||
|
||||
if (PushOut > 0 && !requiresMidPoint)
|
||||
{
|
||||
var offset = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle / 2, PushOut);
|
||||
innerArcStartPoint.Offset(offset.X, offset.Y);
|
||||
innerArcEndPoint.Offset(offset.X, offset.Y);
|
||||
outerArcStartPoint.Offset(offset.X, offset.Y);
|
||||
outerArcEndPoint.Offset(offset.X, offset.Y);
|
||||
}
|
||||
|
||||
var outerArcSize = new Size(Radius, Radius);
|
||||
var innerArcSize = new Size(InnerRadius, InnerRadius);
|
||||
|
||||
if (requiresMidPoint)
|
||||
{
|
||||
context.BeginFigure(innerArcStartPoint, true, true);
|
||||
context.LineTo(outerArcStartPoint, true, true);
|
||||
context.ArcTo(outerArcMidPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true);
|
||||
context.ArcTo(outerArcEndPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true);
|
||||
context.LineTo(innerArcEndPoint, true, true);
|
||||
context.ArcTo(innerArcMidPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
|
||||
context.ArcTo(innerArcStartPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
|
||||
return;
|
||||
}
|
||||
|
||||
context.BeginFigure(innerArcStartPoint, true, true);
|
||||
context.LineTo(outerArcStartPoint, true, true);
|
||||
context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
|
||||
context.LineTo(innerArcEndPoint, true, true);
|
||||
context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class PieUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a coordinate from the polar coordinate system to the cartesian coordinate system.
|
||||
/// </summary>
|
||||
/// <param name="angle"></param>
|
||||
/// <param name="radius"></param>
|
||||
/// <returns></returns>
|
||||
public static Point ComputeCartesianCoordinate(double angle, double radius)
|
||||
{
|
||||
// convert to radians
|
||||
var angleRad = (Math.PI / 180.0) * (angle - 90);
|
||||
|
||||
var x = radius * Math.Cos(angleRad);
|
||||
var y = radius * Math.Sin(angleRad);
|
||||
|
||||
return new Point(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Others/Live-Charts-master/WpfView/Points/PointView.cs
Normal file
58
Others/Live-Charts-master/WpfView/Points/PointView.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
//copyright(c) 2016 Alberto Rodriguez
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class PointView : IChartPointView
|
||||
{
|
||||
public Shape HoverShape { get; set; }
|
||||
public ContentControl DataLabel { get; set; }
|
||||
public bool IsNew { get; set; }
|
||||
public CoreRectangle ValidArea { get; internal set; }
|
||||
|
||||
public virtual void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void OnHover(ChartPoint point)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
196
Others/Live-Charts-master/WpfView/Points/RowPointView.cs
Normal file
196
Others/Live-Charts-master/WpfView/Points/RowPointView.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class RowPointView : PointView, IRectanglePointView
|
||||
{
|
||||
public Rectangle Rectangle { get; set; }
|
||||
public CoreRectangle Data { get; set; }
|
||||
public double ZeroReference { get; set; }
|
||||
public BarLabelPosition LabelPosition { get; set; }
|
||||
private RotateTransform Transform { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
if (IsNew)
|
||||
{
|
||||
Canvas.SetTop(Rectangle, Data.Top);
|
||||
Canvas.SetLeft(Rectangle, ZeroReference);
|
||||
|
||||
Rectangle.Width = 0;
|
||||
Rectangle.Height = Data.Height;
|
||||
}
|
||||
|
||||
if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, Data.Top);
|
||||
Canvas.SetLeft(DataLabel, ZeroReference);
|
||||
}
|
||||
|
||||
Func<double> getY = () =>
|
||||
{
|
||||
if (LabelPosition == BarLabelPosition.Perpendicular)
|
||||
{
|
||||
if (Transform == null)
|
||||
Transform = new RotateTransform(270);
|
||||
|
||||
DataLabel.RenderTransform = Transform;
|
||||
return Data.Top + Data.Height/2 + DataLabel.ActualWidth*.5;
|
||||
}
|
||||
|
||||
var r = Data.Top + Data.Height / 2 - DataLabel.ActualHeight / 2;
|
||||
|
||||
if (r < 0) r = 2;
|
||||
if (r + DataLabel.ActualHeight > chart.DrawMargin.Height)
|
||||
r -= r + DataLabel.ActualHeight - chart.DrawMargin.Height + 2;
|
||||
|
||||
return r;
|
||||
};
|
||||
|
||||
Func<double> getX = () =>
|
||||
{
|
||||
double r;
|
||||
|
||||
#pragma warning disable 618
|
||||
if (LabelPosition == BarLabelPosition.Parallel || LabelPosition == BarLabelPosition.Merged)
|
||||
#pragma warning restore 618
|
||||
{
|
||||
r = Data.Left + Data.Width/2 - DataLabel.ActualWidth/2;
|
||||
}
|
||||
else if (LabelPosition == BarLabelPosition.Perpendicular)
|
||||
{
|
||||
r = Data.Left + Data.Width/2 - DataLabel.ActualHeight/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Data.Left < ZeroReference)
|
||||
{
|
||||
r = Data.Left - DataLabel.ActualWidth - 5;
|
||||
if (r < 0) r = Data.Left + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = Data.Left + Data.Width + 5;
|
||||
if (r + DataLabel.ActualWidth > chart.DrawMargin.Width)
|
||||
r -= DataLabel.ActualWidth + 10;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
};
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
Rectangle.Width = Data.Width;
|
||||
Rectangle.Height = Data.Height;
|
||||
|
||||
Canvas.SetTop(Rectangle, Data.Top);
|
||||
Canvas.SetLeft(Rectangle, Data.Left);
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
Canvas.SetTop(DataLabel, getY());
|
||||
Canvas.SetLeft(DataLabel, getX());
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
Canvas.SetTop(HoverShape, Data.Top);
|
||||
Canvas.SetLeft(HoverShape, Data.Left);
|
||||
HoverShape.Height = Data.Height;
|
||||
HoverShape.Width = Data.Width;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(getX(), animSpeed));
|
||||
DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(getY(), animSpeed));
|
||||
}
|
||||
|
||||
Rectangle.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(Data.Top, animSpeed));
|
||||
Rectangle.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(Data.Left, animSpeed));
|
||||
|
||||
Rectangle.BeginAnimation(FrameworkElement.HeightProperty,
|
||||
new DoubleAnimation(Data.Height, animSpeed));
|
||||
Rectangle.BeginAnimation(FrameworkElement.WidthProperty,
|
||||
new DoubleAnimation(Data.Width, animSpeed));
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
Canvas.SetTop(HoverShape, Data.Top);
|
||||
Canvas.SetLeft(HoverShape, Data.Left);
|
||||
HoverShape.Height = Data.Height;
|
||||
HoverShape.Width = Data.Width;
|
||||
}
|
||||
}
|
||||
|
||||
public override void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(HoverShape);
|
||||
chart.View.RemoveFromDrawMargin(Rectangle);
|
||||
chart.View.RemoveFromDrawMargin(DataLabel);
|
||||
}
|
||||
|
||||
public override void OnHover(ChartPoint point)
|
||||
{
|
||||
var copy = Rectangle.Fill.Clone();
|
||||
copy.Opacity -= .15;
|
||||
Rectangle.Fill = copy;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
if (Rectangle == null) return;
|
||||
|
||||
if (point.Fill != null)
|
||||
{
|
||||
Rectangle.Fill = (Brush)point.Fill;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle.Fill = ((Series) point.SeriesView).Fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
157
Others/Live-Charts-master/WpfView/Points/ScatterPointView.cs
Normal file
157
Others/Live-Charts-master/WpfView/Points/ScatterPointView.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class ScatterPointView : PointView, IScatterPointView
|
||||
{
|
||||
public Shape Shape { get; set; }
|
||||
public double Diameter { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
if (IsNew)
|
||||
{
|
||||
Canvas.SetTop(Shape, current.ChartLocation.Y);
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X);
|
||||
|
||||
Shape.Width = 0;
|
||||
Shape.Height = 0;
|
||||
}
|
||||
|
||||
if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, current.ChartLocation.Y);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X);
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
HoverShape.Width = Diameter;
|
||||
HoverShape.Height = Diameter;
|
||||
Canvas.SetLeft(HoverShape, current.ChartLocation.X - Diameter / 2);
|
||||
Canvas.SetTop(HoverShape, current.ChartLocation.Y - Diameter / 2);
|
||||
}
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
Shape.Width = Diameter;
|
||||
Shape.Height = Diameter;
|
||||
|
||||
Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height*.5);
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width*.5);
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth*.5, chart);
|
||||
var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight*.5, chart);
|
||||
|
||||
Canvas.SetTop(DataLabel, cy);
|
||||
Canvas.SetLeft(DataLabel, cx);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
var cx = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth*.5, chart);
|
||||
var cy = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight*.5, chart);
|
||||
|
||||
DataLabel.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(cx, animSpeed));
|
||||
DataLabel.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(cy, animSpeed));
|
||||
}
|
||||
|
||||
Shape.BeginAnimation(FrameworkElement.WidthProperty,
|
||||
new DoubleAnimation(Diameter, animSpeed));
|
||||
Shape.BeginAnimation(FrameworkElement.HeightProperty,
|
||||
new DoubleAnimation(Diameter, animSpeed));
|
||||
|
||||
Shape.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(current.ChartLocation.Y - Diameter*.5, animSpeed));
|
||||
Shape.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(current.ChartLocation.X - Diameter*.5, animSpeed));
|
||||
}
|
||||
|
||||
public override void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(HoverShape);
|
||||
chart.View.RemoveFromDrawMargin(Shape);
|
||||
chart.View.RemoveFromDrawMargin(DataLabel);
|
||||
}
|
||||
|
||||
protected double CorrectXLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
if (desiredPosition + DataLabel.ActualWidth > chart.DrawMargin.Width)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualWidth - chart.DrawMargin.Width;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
|
||||
protected double CorrectYLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
if (desiredPosition + DataLabel.ActualHeight > chart.DrawMargin.Height)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualHeight - chart.DrawMargin.Height;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
|
||||
public override void OnHover(ChartPoint point)
|
||||
{
|
||||
var copy = Shape.Fill.Clone();
|
||||
copy.Opacity -= .15;
|
||||
Shape.Fill = copy;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
if (Shape == null) return;
|
||||
|
||||
if (point.Fill != null)
|
||||
{
|
||||
Shape.Fill = (Brush) point.Fill;
|
||||
}
|
||||
else
|
||||
{
|
||||
Shape.Fill = ((Series) point.SeriesView).Fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
249
Others/Live-Charts-master/WpfView/Points/StepLinePointView.cs
Normal file
249
Others/Live-Charts-master/WpfView/Points/StepLinePointView.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class StepLinePointView : PointView, IStepPointView
|
||||
{
|
||||
public double DeltaX { get; set; }
|
||||
public double DeltaY { get; set; }
|
||||
public Line Line1 { get; set; }
|
||||
public Line Line2 { get; set; }
|
||||
public Path Shape { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
var invertedMode = ((StepLineSeries) current.SeriesView).InvertedMode;
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
if (invertedMode)
|
||||
{
|
||||
Line1.X1 = current.ChartLocation.X;
|
||||
Line1.X2 = current.ChartLocation.X - DeltaX;
|
||||
Line1.Y1 = chart.DrawMargin.Height;
|
||||
Line1.Y2 = chart.DrawMargin.Height;
|
||||
|
||||
Line2.X1 = current.ChartLocation.X - DeltaX;
|
||||
Line2.X2 = current.ChartLocation.X - DeltaX;
|
||||
Line2.Y1 = chart.DrawMargin.Height;
|
||||
Line2.Y2 = chart.DrawMargin.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Line1.X1 = current.ChartLocation.X;
|
||||
Line1.X2 = current.ChartLocation.X;
|
||||
Line1.Y1 = chart.DrawMargin.Height;
|
||||
Line1.Y2 = chart.DrawMargin.Height;
|
||||
|
||||
Line2.X1 = current.ChartLocation.X - DeltaX;
|
||||
Line2.X2 = current.ChartLocation.X;
|
||||
Line2.Y1 = chart.DrawMargin.Height;
|
||||
Line2.Y2 = chart.DrawMargin.Height;
|
||||
}
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width/2);
|
||||
Canvas.SetTop(Shape, chart.DrawMargin.Height);
|
||||
}
|
||||
}
|
||||
|
||||
if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, chart.DrawMargin.Height);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X);
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
HoverShape.Width = Shape != null ? (Shape.Width > 5 ? Shape.Width : 5) : 5;
|
||||
HoverShape.Height = Shape != null ? (Shape.Height > 5 ? Shape.Height : 5) : 5;
|
||||
Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width / 2);
|
||||
Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height / 2);
|
||||
}
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
if (invertedMode)
|
||||
{
|
||||
Line1.X1 = current.ChartLocation.X;
|
||||
Line1.X2 = current.ChartLocation.X - DeltaX;
|
||||
Line1.Y1 = current.ChartLocation.Y;
|
||||
Line1.Y2 = current.ChartLocation.Y;
|
||||
|
||||
Line2.X1 = current.ChartLocation.X - DeltaX;
|
||||
Line2.X2 = current.ChartLocation.X - DeltaX;
|
||||
Line2.Y1 = current.ChartLocation.Y;
|
||||
Line2.Y2 = current.ChartLocation.Y - DeltaY;
|
||||
}
|
||||
else
|
||||
{
|
||||
Line1.X1 = current.ChartLocation.X;
|
||||
Line1.X2 = current.ChartLocation.X;
|
||||
Line1.Y1 = current.ChartLocation.Y;
|
||||
Line1.Y2 = current.ChartLocation.Y - DeltaY;
|
||||
|
||||
Line2.X1 = current.ChartLocation.X - DeltaX;
|
||||
Line2.X2 = current.ChartLocation.X;
|
||||
Line2.Y1 = current.ChartLocation.Y - DeltaY;
|
||||
Line2.Y2 = current.ChartLocation.Y - DeltaY;
|
||||
}
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width/2);
|
||||
Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height/2);
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart);
|
||||
var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart);
|
||||
Canvas.SetLeft(DataLabel, xl);
|
||||
Canvas.SetTop(DataLabel, yl);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
if (invertedMode)
|
||||
{
|
||||
Line1.BeginAnimation(Line.X1Property,
|
||||
new DoubleAnimation(current.ChartLocation.X, animSpeed));
|
||||
Line1.BeginAnimation(Line.X2Property,
|
||||
new DoubleAnimation(current.ChartLocation.X - DeltaX, animSpeed));
|
||||
Line1.BeginAnimation(Line.Y1Property,
|
||||
new DoubleAnimation(current.ChartLocation.Y, animSpeed));
|
||||
Line1.BeginAnimation(Line.Y2Property,
|
||||
new DoubleAnimation(current.ChartLocation.Y, animSpeed));
|
||||
|
||||
Line2.BeginAnimation(Line.X1Property,
|
||||
new DoubleAnimation(current.ChartLocation.X - DeltaX, animSpeed));
|
||||
Line2.BeginAnimation(Line.X2Property,
|
||||
new DoubleAnimation(current.ChartLocation.X - DeltaX, animSpeed));
|
||||
Line2.BeginAnimation(Line.Y1Property,
|
||||
new DoubleAnimation(current.ChartLocation.Y, animSpeed));
|
||||
Line2.BeginAnimation(Line.Y2Property,
|
||||
new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));
|
||||
}
|
||||
else
|
||||
{
|
||||
Line1.BeginAnimation(Line.X1Property,
|
||||
new DoubleAnimation(current.ChartLocation.X, animSpeed));
|
||||
Line1.BeginAnimation(Line.X2Property,
|
||||
new DoubleAnimation(current.ChartLocation.X, animSpeed));
|
||||
Line1.BeginAnimation(Line.Y1Property,
|
||||
new DoubleAnimation(current.ChartLocation.Y, animSpeed));
|
||||
Line1.BeginAnimation(Line.Y2Property,
|
||||
new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));
|
||||
|
||||
Line2.BeginAnimation(Line.X1Property,
|
||||
new DoubleAnimation(current.ChartLocation.X - DeltaX, animSpeed));
|
||||
Line2.BeginAnimation(Line.X2Property,
|
||||
new DoubleAnimation(current.ChartLocation.X, animSpeed));
|
||||
Line2.BeginAnimation(Line.Y1Property,
|
||||
new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));
|
||||
Line2.BeginAnimation(Line.Y2Property,
|
||||
new DoubleAnimation(current.ChartLocation.Y - DeltaY, animSpeed));
|
||||
}
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Shape.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(current.ChartLocation.X - Shape.Width/2, animSpeed));
|
||||
Shape.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(current.ChartLocation.Y - Shape.Height/2, animSpeed));
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart);
|
||||
var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart);
|
||||
Canvas.SetLeft(DataLabel, xl);
|
||||
Canvas.SetTop(DataLabel, yl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void RemoveFromView(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(HoverShape);
|
||||
chart.View.RemoveFromDrawMargin(Shape);
|
||||
chart.View.RemoveFromDrawMargin(DataLabel);
|
||||
chart.View.RemoveFromDrawMargin(Line1);
|
||||
chart.View.RemoveFromDrawMargin(Line2);
|
||||
}
|
||||
|
||||
public override void OnHover(ChartPoint point)
|
||||
{
|
||||
var lineSeries = (StepLineSeries) point.SeriesView;
|
||||
if (Shape != null) Shape.Fill = Shape.Stroke;
|
||||
lineSeries.StrokeThickness = lineSeries.StrokeThickness + 1;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
var lineSeries = (StepLineSeries) point.SeriesView;
|
||||
if (Shape != null)
|
||||
Shape.Fill = point.Fill == null
|
||||
? lineSeries.PointForeground
|
||||
: (Brush) point.Fill;
|
||||
lineSeries.StrokeThickness = lineSeries.StrokeThickness - 1;
|
||||
}
|
||||
|
||||
protected double CorrectXLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
if (desiredPosition + DataLabel.ActualWidth * .5 < -0.1) return -DataLabel.ActualWidth;
|
||||
|
||||
if (desiredPosition + DataLabel.ActualWidth > chart.DrawMargin.Width)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualWidth - chart.DrawMargin.Width + 2;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
|
||||
protected double CorrectYLabel(double desiredPosition, ChartCore chart)
|
||||
{
|
||||
desiredPosition -= (Shape == null ? 0 : Shape.ActualHeight * .5) + DataLabel.ActualHeight * .5 + 2;
|
||||
|
||||
if (desiredPosition + DataLabel.ActualHeight > chart.DrawMargin.Height)
|
||||
desiredPosition -= desiredPosition + DataLabel.ActualHeight - chart.DrawMargin.Height + 2;
|
||||
|
||||
if (desiredPosition < 0) desiredPosition = 0;
|
||||
|
||||
return desiredPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Dtos;
|
||||
|
||||
namespace LiveCharts.Wpf.Points
|
||||
{
|
||||
internal class VerticalBezierPointView : HorizontalBezierPointView
|
||||
{
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
var previosPbv = previousDrawn == null ? null : (VerticalBezierPointView) previousDrawn.View;
|
||||
|
||||
Container.Segments.Remove(Segment);
|
||||
Container.Segments.Insert(index, Segment);
|
||||
|
||||
ValidArea = new CoreRectangle(current.ChartLocation.X - 7.5, current.ChartLocation.Y - 7.5, 15, 15);
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
if (previosPbv != null && !previosPbv.IsNew)
|
||||
{
|
||||
Segment.Point1 = previosPbv.Segment.Point3;
|
||||
Segment.Point2 = previosPbv.Segment.Point3;
|
||||
Segment.Point3 = previosPbv.Segment.Point3;
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
Canvas.SetTop(DataLabel, Canvas.GetTop(previosPbv.DataLabel));
|
||||
Canvas.SetLeft(DataLabel, Canvas.GetLeft(previosPbv.DataLabel));
|
||||
}
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetTop(Shape, Canvas.GetTop(previosPbv.Shape));
|
||||
Canvas.SetLeft(Shape, Canvas.GetLeft(previosPbv.Shape));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (current.SeriesView.IsFirstDraw)
|
||||
{
|
||||
Segment.Point1 = new Point(0, Data.Point1.Y);
|
||||
Segment.Point2 = new Point(0, Data.Point2.Y);
|
||||
Segment.Point3 = new Point(0, Data.Point3.Y);
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5);
|
||||
Canvas.SetLeft(Shape, 0);
|
||||
}
|
||||
if (DataLabel != null)
|
||||
{
|
||||
Canvas.SetTop(DataLabel, current.ChartLocation.Y - DataLabel.ActualHeight * .5);
|
||||
Canvas.SetLeft(DataLabel, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var startPoint = ((LineSeries) current.SeriesView).Splitters[0].Left.Point;
|
||||
Segment.Point1 = startPoint;
|
||||
Segment.Point2 = startPoint;
|
||||
Segment.Point3 = startPoint;
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetTop(Shape, startPoint.Y - Shape.Height * .5);
|
||||
Canvas.SetLeft(Shape, startPoint.X);
|
||||
}
|
||||
if (DataLabel != null)
|
||||
{
|
||||
Canvas.SetTop(DataLabel, startPoint.Y - DataLabel.ActualHeight * .5);
|
||||
Canvas.SetLeft(DataLabel, startPoint.X);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, current.ChartLocation.Y - DataLabel.ActualHeight * .5);
|
||||
Canvas.SetLeft(DataLabel, 0);
|
||||
}
|
||||
|
||||
#region No Animated
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
Segment.Point1 = Data.Point1.AsPoint();
|
||||
Segment.Point2 = Data.Point2.AsPoint();
|
||||
Segment.Point3 = Data.Point3.AsPoint();
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width * .5);
|
||||
Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height * .5);
|
||||
}
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5);
|
||||
Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5);
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart);
|
||||
var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart);
|
||||
Canvas.SetLeft(DataLabel, xl);
|
||||
Canvas.SetTop(DataLabel, yl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Segment.BeginAnimation(BezierSegment.Point1Property,
|
||||
new PointAnimation(Segment.Point1, Data.Point1.AsPoint(), chart.View.AnimationsSpeed));
|
||||
Segment.BeginAnimation(BezierSegment.Point2Property,
|
||||
new PointAnimation(Segment.Point2, Data.Point2.AsPoint(), chart.View.AnimationsSpeed));
|
||||
Segment.BeginAnimation(BezierSegment.Point3Property,
|
||||
new PointAnimation(Segment.Point3, Data.Point3.AsPoint(), chart.View.AnimationsSpeed));
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
if (double.IsNaN(Canvas.GetLeft(Shape)))
|
||||
{
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width * .5);
|
||||
Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5);
|
||||
}
|
||||
else
|
||||
{
|
||||
Shape.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(current.ChartLocation.X - Shape.Width * .5, chart.View.AnimationsSpeed));
|
||||
Shape.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(current.ChartLocation.Y - Shape.Height * .5, chart.View.AnimationsSpeed));
|
||||
}
|
||||
}
|
||||
|
||||
if (DataLabel != null)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
var xl = CorrectXLabel(current.ChartLocation.X - DataLabel.ActualWidth * .5, chart);
|
||||
var yl = CorrectYLabel(current.ChartLocation.Y - DataLabel.ActualHeight * .5, chart);
|
||||
|
||||
DataLabel.BeginAnimation(Canvas.LeftProperty,
|
||||
new DoubleAnimation(xl, chart.View.AnimationsSpeed));
|
||||
DataLabel.BeginAnimation(Canvas.TopProperty,
|
||||
new DoubleAnimation(yl, chart.View.AnimationsSpeed));
|
||||
}
|
||||
|
||||
if (HoverShape != null)
|
||||
{
|
||||
Canvas.SetLeft(HoverShape, current.ChartLocation.X - HoverShape.Width * .5);
|
||||
Canvas.SetTop(HoverShape, current.ChartLocation.Y - HoverShape.Height * .5);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHover(ChartPoint point)
|
||||
{
|
||||
var lineSeries = (LineSeries)point.SeriesView;
|
||||
if (Shape != null) Shape.Fill = Shape.Stroke;
|
||||
lineSeries.Path.StrokeThickness = lineSeries.StrokeThickness + 1;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
var lineSeries = (LineSeries)point.SeriesView;
|
||||
if (Shape != null)
|
||||
Shape.Fill = point.Fill == null
|
||||
? lineSeries.PointForeground
|
||||
: (Brush) point.Fill;
|
||||
lineSeries.Path.StrokeThickness = lineSeries.StrokeThickness;
|
||||
}
|
||||
}
|
||||
}
|
||||
61
Others/Live-Charts-master/WpfView/Properties/AssemblyInfo.cs
Normal file
61
Others/Live-Charts-master/WpfView/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("LiveCharts.Wpf")]
|
||||
[assembly: AssemblyDescription("LiveCharts view for wpf")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LiveCharts.Wpf")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016 Alberto Rodríguez Orozco")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly:ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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.5")]
|
||||
[assembly: AssemblyFileVersion("0.9.5")]
|
||||
|
||||
[assembly: InternalsVisibleTo("LiveCharts.Geared")]
|
||||
[assembly: InternalsVisibleTo("LiveCharts.WinForms")]
|
||||
|
||||
[assembly: InternalsVisibleTo("LiveCharts.Geared,PublicKey=0024000004800000940000000602000000240000525341310004000001000100bd2e66fab8ce9a4900047ffda57d2f525cf6313dcc9d20994c5e6b3cd8fca906ba7ccd54bea5f7bd6cb503deb81d685259e355e3a9b5c21e5bc80091f08846246371b2a71ab306655651261e910adfa61be236b77d11df23a44d48f00a0e07c689f9a2daaff16d505a1c861d9854d92ed5a8a38fb28c1343fb691462873e71a1")]
|
||||
[assembly: InternalsVisibleTo("LiveCharts.WinForms,PublicKey=0024000004800000940000000602000000240000525341310004000001000100350c0d66a049ff682dde73f82292f9f6fc3da862f96726095d135cbb1e37f338312b771c89616ee6d241447293585eb53522aed80ba396f196d8108beba690c5563b45a10a8202b67e0e9e01d5843871a74bf8715463550f10f3004e5a1ed8727e48afc64822c7286bd3dc6c6e1439d910d762d9d7ed65ef32ac1fd633bc35c4")]
|
||||
63
Others/Live-Charts-master/WpfView/Properties/Resources.Designer.cs
generated
Normal file
63
Others/Live-Charts-master/WpfView/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace LiveCharts.Wpf.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LiveCharts.Wpf.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Others/Live-Charts-master/WpfView/Properties/Resources.resx
Normal file
117
Others/Live-Charts-master/WpfView/Properties/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
26
Others/Live-Charts-master/WpfView/Properties/Settings.Designer.cs
generated
Normal file
26
Others/Live-Charts-master/WpfView/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace LiveCharts.Wpf.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
231
Others/Live-Charts-master/WpfView/RowSeries.cs
Normal file
231
Others/Live-Charts-master/WpfView/RowSeries.cs
Normal file
@@ -0,0 +1,231 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The Row series plots horizontal bars in a cartesian chart
|
||||
/// </summary>
|
||||
public class RowSeries : Series, IRowSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of RowSeries class
|
||||
/// </summary>
|
||||
public RowSeries()
|
||||
{
|
||||
Model = new RowAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of RowSeries class with a given mapper
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public RowSeries(object configuration)
|
||||
{
|
||||
Model = new RowAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The maximum row heigth property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxRowHeigthProperty = DependencyProperty.Register(
|
||||
"MaxRowHeigth", typeof (double), typeof (RowSeries), new PropertyMetadata(35d));
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum row height, the height of a column will be capped at this value
|
||||
/// </summary>
|
||||
public double MaxRowHeigth
|
||||
{
|
||||
get { return (double) GetValue(MaxRowHeigthProperty); }
|
||||
set { SetValue(MaxRowHeigthProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The row padding property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RowPaddingProperty = DependencyProperty.Register(
|
||||
"RowPadding", typeof (double), typeof (RowSeries), new PropertyMetadata(2d));
|
||||
/// <summary>
|
||||
/// Gets or sets the padding between rows in this series
|
||||
/// </summary>
|
||||
public double RowPadding
|
||||
{
|
||||
get { return (double) GetValue(RowPaddingProperty); }
|
||||
set { SetValue(RowPaddingProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The labels position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelsPositionProperty = DependencyProperty.Register(
|
||||
"LabelsPosition", typeof(BarLabelPosition), typeof(RowSeries),
|
||||
new PropertyMetadata(default(BarLabelPosition), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets where the label is placed
|
||||
/// </summary>
|
||||
public BarLabelPosition LabelsPosition
|
||||
{
|
||||
get { return (BarLabelPosition)GetValue(LabelsPositionProperty); }
|
||||
set { SetValue(LabelsPositionProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The shares position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SharesPositionProperty = DependencyProperty.Register(
|
||||
"SharesPosition", typeof(bool), typeof(RowSeries), new PropertyMetadata(default(bool)));
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this row shares space with all the row series in the same position
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [shares position]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool SharesPosition
|
||||
{
|
||||
get { return (bool)GetValue(SharesPositionProperty); }
|
||||
set { SetValue(SharesPositionProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point view.
|
||||
/// </summary>
|
||||
/// <param name="point">The point.</param>
|
||||
/// <param name="label">The label.</param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (RowPointView)point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new RowPointView
|
||||
{
|
||||
IsNew = true,
|
||||
Rectangle = new Rectangle(),
|
||||
Data = new CoreRectangle()
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Rectangle);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
pbv.Rectangle.Fill = Fill;
|
||||
pbv.Rectangle.Stroke = Stroke;
|
||||
pbv.Rectangle.StrokeThickness = StrokeThickness;
|
||||
pbv.Rectangle.StrokeDashArray = StrokeDashArray;
|
||||
pbv.Rectangle.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.Rectangle, Panel.GetZIndex(this));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
if (point.Stroke != null) pbv.Rectangle.Stroke = (Brush)point.Stroke;
|
||||
if (point.Fill != null) pbv.Rectangle.Fill = (Brush)point.Fill;
|
||||
|
||||
pbv.LabelPosition = LabelsPosition;
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
SetCurrentValue(MaxRowHeigthProperty, 35d);
|
||||
SetCurrentValue(RowPaddingProperty, 2d);
|
||||
SetCurrentValue(LabelsPositionProperty, BarLabelPosition.Top);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => x.EvaluatesGantt
|
||||
? string.Format("starts {0}, ends {1}", Model.CurrentXAxis.GetFormatter()(x.XStart),
|
||||
Model.CurrentXAxis.GetFormatter()(x.X))
|
||||
: Model.CurrentXAxis.GetFormatter()(x.X);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
211
Others/Live-Charts-master/WpfView/ScatterSeries.cs
Normal file
211
Others/Live-Charts-master/WpfView/ScatterSeries.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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.SeriesAlgorithms;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
using LiveCharts.Wpf.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The Bubble series, draws scatter series, only using X and Y properties or bubble series, if you also use the weight property, this series should be used in a cartesian chart.
|
||||
/// </summary>
|
||||
public class ScatterSeries : Series, IScatterSeriesView, IAreaPoint
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of BubbleSeries class
|
||||
/// </summary>
|
||||
public ScatterSeries()
|
||||
{
|
||||
Model = new ScatterAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of BubbleSeries class using a given mapper
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public ScatterSeries(object configuration)
|
||||
{
|
||||
Model = new ScatterAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The maximum point shape diameter property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxPointShapeDiameterProperty = DependencyProperty.Register(
|
||||
"MaxPointShapeDiameter", typeof (double), typeof (ScatterSeries),
|
||||
new PropertyMetadata(default(double), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the max shape diameter, the points using the max weight in the series will have this radius.
|
||||
/// </summary>
|
||||
public double MaxPointShapeDiameter
|
||||
{
|
||||
get { return (double) GetValue(MaxPointShapeDiameterProperty); }
|
||||
set { SetValue(MaxPointShapeDiameterProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The minimum point shape diameter property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MinPointShapeDiameterProperty = DependencyProperty.Register(
|
||||
"MinPointShapeDiameter", typeof (double), typeof (ScatterSeries),
|
||||
new PropertyMetadata(default(double), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the min shape diameter, the points using the min weight in the series will have this radius.
|
||||
/// </summary>
|
||||
public double MinPointShapeDiameter
|
||||
{
|
||||
get { return (double) GetValue(MinPointShapeDiameterProperty); }
|
||||
set { SetValue(MinPointShapeDiameterProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Gets the point diameter.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public double GetPointDiameter()
|
||||
{
|
||||
return MaxPointShapeDiameter/2;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (ScatterPointView) point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new ScatterPointView
|
||||
{
|
||||
IsNew = true,
|
||||
Shape = new Path
|
||||
{
|
||||
Stretch = Stretch.Fill,
|
||||
StrokeThickness = StrokeThickness
|
||||
}
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Shape);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Shape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
var p = (Path) pbv.Shape;
|
||||
p.Data = PointGeometry;
|
||||
p.Fill = Fill;
|
||||
p.Stroke = Stroke;
|
||||
p.StrokeThickness = StrokeThickness;
|
||||
p.Visibility = Visibility;
|
||||
Panel.SetZIndex(p, Panel.GetZIndex(this));
|
||||
p.StrokeDashArray = StrokeDashArray;
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
if (point.Stroke != null) pbv.Shape.Stroke = (Brush)point.Stroke;
|
||||
if (point.Fill != null) pbv.Shape.Fill = (Brush)point.Fill;
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
SetCurrentValue(MaxPointShapeDiameterProperty, 15d);
|
||||
SetCurrentValue(MinPointShapeDiameterProperty, 10d);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentXAxis.GetFormatter()(x.X) + ", "
|
||||
+ Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.7;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
51
Others/Live-Charts-master/WpfView/SectionsCollection.cs
Normal file
51
Others/Live-Charts-master/WpfView/SectionsCollection.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using LiveCharts.Helpers;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The SectionsCollection class holds a collection of Axis.Sections
|
||||
/// </summary>
|
||||
public class SectionsCollection : NoisyCollection<AxisSection>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of SectionsCollection instance
|
||||
/// </summary>
|
||||
public SectionsCollection()
|
||||
{
|
||||
NoisyCollectionChanged += OnNoisyCollectionChanged;
|
||||
}
|
||||
|
||||
private static void OnNoisyCollectionChanged(IEnumerable<AxisSection> oldItems, IEnumerable<AxisSection> newItems)
|
||||
{
|
||||
if (oldItems == null) return;
|
||||
|
||||
foreach (var oldSection in oldItems)
|
||||
{
|
||||
oldSection.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
179
Others/Live-Charts-master/WpfView/Separator.cs
Normal file
179
Others/Live-Charts-master/WpfView/Separator.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an Axis.Separator, this class customizes the separator of an axis.
|
||||
/// </summary>
|
||||
public class Separator : FrameworkElement, ISeparatorView
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Separator class
|
||||
/// </summary>
|
||||
public Separator()
|
||||
{
|
||||
SetCurrentValue(IsEnabledProperty, true);
|
||||
SetCurrentValue(StrokeProperty, new SolidColorBrush(Color.FromRgb(240, 240, 240)));
|
||||
SetCurrentValue(StrokeThicknessProperty, 1d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the chart the own the separator
|
||||
/// </summary>
|
||||
public ChartCore Chart { get; set; }
|
||||
private AxisCore Axis { get; set; }
|
||||
|
||||
#region Dependency Properties
|
||||
|
||||
/// <summary>
|
||||
/// The stroke property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register(
|
||||
"Stroke", typeof (Brush), typeof (Separator),
|
||||
new PropertyMetadata(default(Brush), CallChartUpdater()));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets separators color
|
||||
/// </summary>
|
||||
public Brush Stroke
|
||||
{
|
||||
get { return (Brush) GetValue(StrokeProperty); }
|
||||
set { SetValue(StrokeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stroke thickness property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register(
|
||||
"StrokeThickness", typeof (double), typeof (Separator),
|
||||
new PropertyMetadata(default(double), CallChartUpdater()));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets separators thickness
|
||||
/// </summary>
|
||||
public double StrokeThickness
|
||||
{
|
||||
get { return (double) GetValue(StrokeThicknessProperty); }
|
||||
set { SetValue(StrokeThicknessProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stroke dash array property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeDashArrayProperty = DependencyProperty.Register(
|
||||
"StrokeDashArray", typeof (DoubleCollection), typeof (Separator),
|
||||
new PropertyMetadata(default(DoubleCollection), CallChartUpdater()));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the stroke dash array for the current separator.
|
||||
/// </summary>
|
||||
public DoubleCollection StrokeDashArray
|
||||
{
|
||||
get { return (DoubleCollection) GetValue(StrokeDashArrayProperty); }
|
||||
set { SetValue(StrokeDashArrayProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The step property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StepProperty = DependencyProperty.Register(
|
||||
"Step", typeof (double), typeof (Separator),
|
||||
new PropertyMetadata(double.NaN, CallChartUpdater()));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets separators step, this means the value between each line, default is null, when null this value is calculated automatically.
|
||||
/// </summary>
|
||||
public double Step
|
||||
{
|
||||
get { return (double) GetValue(StepProperty); }
|
||||
set { SetValue(StepProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The actual step property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ActualStepProperty = DependencyProperty.Register(
|
||||
"ActualStep", typeof(double), typeof(Separator), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets the actual step.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The actual step.
|
||||
/// </value>
|
||||
public double ActualStep
|
||||
{
|
||||
get { return Axis.S; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The axis orientation property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty AxisOrientationProperty = DependencyProperty.Register(
|
||||
"AxisOrientation", typeof(AxisOrientation), typeof(Separator), new PropertyMetadata(default(AxisOrientation)));
|
||||
/// <summary>
|
||||
/// Gets or sets the element orientation ind the axis
|
||||
/// </summary>
|
||||
public AxisOrientation AxisOrientation
|
||||
{
|
||||
get { return (AxisOrientation)GetValue(AxisOrientationProperty); }
|
||||
internal set { SetValue(AxisOrientationProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Ases the core element.
|
||||
/// </summary>
|
||||
/// <param name="axis">The axis.</param>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
public SeparatorConfigurationCore AsCoreElement(AxisCore axis, AxisOrientation source)
|
||||
{
|
||||
AxisOrientation = source;
|
||||
Chart = axis.Chart;
|
||||
Axis = axis;
|
||||
return new SeparatorConfigurationCore(axis)
|
||||
{
|
||||
IsEnabled = IsEnabled,
|
||||
Step = Step,
|
||||
Source = source
|
||||
};
|
||||
}
|
||||
|
||||
private static PropertyChangedCallback CallChartUpdater(bool animate = false)
|
||||
{
|
||||
return (o, args) =>
|
||||
{
|
||||
var wpfSeparator = o as Separator;
|
||||
if (wpfSeparator == null) return;
|
||||
|
||||
if (wpfSeparator.Chart != null) wpfSeparator.Chart.Updater.Run(animate);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
607
Others/Live-Charts-master/WpfView/Series.cs
Normal file
607
Others/Live-Charts-master/WpfView/Series.cs
Normal file
@@ -0,0 +1,607 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using LiveCharts.Defaults;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.Helpers;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
using LiveCharts.Wpf.Components;
|
||||
using LiveCharts.Wpf.Converters;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Base WPF and WinForms series, this class is abstract
|
||||
/// </summary>
|
||||
public abstract class Series : FrameworkElement, ISeriesView
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new Instance of Series
|
||||
/// </summary>
|
||||
protected Series()
|
||||
{
|
||||
DefaultFillOpacity = 0.35;
|
||||
SetCurrentValue(TitleProperty, "Series");
|
||||
IsVisibleChanged += OnIsVisibleChanged;
|
||||
IsFirstDraw = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Instance of series, with a given configuration
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
protected Series(object configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
SetValue(TitleProperty, "Series");
|
||||
IsVisibleChanged += OnIsVisibleChanged;
|
||||
IsFirstDraw = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
private IChartValues LastKnownValues { get; set; }
|
||||
internal double DefaultFillOpacity { get; set; }
|
||||
/// <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>
|
||||
public bool IsFirstDraw { get; internal set; }
|
||||
/// <summary>
|
||||
/// THe Model is set by every series type, it is the motor of the series, it is the communication with the core of the library
|
||||
/// </summary>
|
||||
public SeriesAlgorithm Model { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the Actual values in the series, active or visible series only
|
||||
/// </summary>
|
||||
public IChartValues ActualValues
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DesignerProperties.GetIsInDesignMode(this) && (Values == null || Values.Count == 0))
|
||||
SetValue(ValuesProperty, GetValuesForDesigner());
|
||||
|
||||
return Values ?? new ChartValues<double>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the series is visible
|
||||
/// </summary>
|
||||
public bool IsSeriesVisible
|
||||
{
|
||||
get { return Visibility == Visibility.Visible; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current chart points in the series
|
||||
/// </summary>
|
||||
public IEnumerable<ChartPoint> ChartPoints
|
||||
{
|
||||
get { return ActualValues.GetPoints(this); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The values property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ValuesProperty = DependencyProperty.Register(
|
||||
"Values", typeof (IChartValues), typeof (Series),
|
||||
new PropertyMetadata(default(IChartValues), OnValuesInstanceChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets chart values.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(NumericChartValuesConverter))]
|
||||
public IChartValues Values
|
||||
{
|
||||
get { return ThreadAccess.Resolve<IChartValues>(this, ValuesProperty); }
|
||||
set { SetValue(ValuesProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The title property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
|
||||
"Title", typeof (string), typeof (Series),
|
||||
new PropertyMetadata(default(string), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets series title
|
||||
/// </summary>
|
||||
public string Title
|
||||
{
|
||||
get { return (string) GetValue(TitleProperty); }
|
||||
set { SetValue(TitleProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stroke property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register(
|
||||
"Stroke", typeof (Brush), typeof (Series),
|
||||
new PropertyMetadata(default(Brush), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets series stroke, if this property is null then a SolidColorBrush will be assigned according to series position in collection and Chart.Colors property
|
||||
/// </summary>
|
||||
public Brush Stroke
|
||||
{
|
||||
get { return (Brush) GetValue(StrokeProperty); }
|
||||
set { SetValue(StrokeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stroke thickness property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register(
|
||||
"StrokeThickness", typeof (double), typeof (Series),
|
||||
new PropertyMetadata(default(double), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the series stroke thickness.
|
||||
/// </summary>
|
||||
public double StrokeThickness
|
||||
{
|
||||
get { return (double) GetValue(StrokeThicknessProperty); }
|
||||
set { SetValue(StrokeThicknessProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fill property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FillProperty = DependencyProperty.Register(
|
||||
"Fill", typeof (Brush), typeof (Series),
|
||||
new PropertyMetadata(default(Brush), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets series fill color, if this property is null then a SolidColorBrush will be assigned according to series position in collection and Chart.Colors property, also Fill property has a default opacity according to chart type.
|
||||
/// </summary>
|
||||
public Brush Fill
|
||||
{
|
||||
get { return (Brush) GetValue(FillProperty); }
|
||||
set { SetValue(FillProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The data labels property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DataLabelsProperty = DependencyProperty.Register(
|
||||
"DataLabels", typeof (bool), typeof (Series),
|
||||
new PropertyMetadata(default(bool), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets if series should include a label over each data point.
|
||||
/// </summary>
|
||||
public bool DataLabels
|
||||
{
|
||||
get { return (bool) GetValue(DataLabelsProperty); }
|
||||
set { SetValue(DataLabelsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The labels template property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DataLabelsTemplateProperty = DependencyProperty.Register(
|
||||
"DataLabelsTemplate", typeof(DataTemplate), typeof(Series),
|
||||
new PropertyMetadata(DefaultXamlReader.DataLabelTemplate(), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the labels template.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The labels template.
|
||||
/// </value>
|
||||
public DataTemplate DataLabelsTemplate
|
||||
{
|
||||
get { return (DataTemplate) GetValue(DataLabelsTemplateProperty); }
|
||||
set { SetValue(DataLabelsTemplateProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font family property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontFamilyProperty = DependencyProperty.Register(
|
||||
"FontFamily", typeof (FontFamily), typeof (Series),
|
||||
new PropertyMetadata(new FontFamily("Segoe UI")));
|
||||
/// <summary>
|
||||
/// Gets or sets labels font family
|
||||
/// </summary>
|
||||
public FontFamily FontFamily
|
||||
{
|
||||
get { return (FontFamily) GetValue(FontFamilyProperty); }
|
||||
set { SetValue(FontFamilyProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font size property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontSizeProperty = DependencyProperty.Register(
|
||||
"FontSize", typeof (double),
|
||||
typeof (Series), new PropertyMetadata(10d, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets labels font size
|
||||
/// </summary>
|
||||
public double FontSize
|
||||
{
|
||||
get { return (double)GetValue(FontSizeProperty); }
|
||||
set { SetValue(FontSizeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font weight property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontWeightProperty = DependencyProperty.Register(
|
||||
"FontWeight", typeof (FontWeight), typeof (Series),
|
||||
new PropertyMetadata(FontWeights.Bold, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets labels font weight
|
||||
/// </summary>
|
||||
public FontWeight FontWeight
|
||||
{
|
||||
get { return (FontWeight)GetValue(FontWeightProperty); }
|
||||
set { SetValue(FontWeightProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font style property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontStyleProperty = DependencyProperty.Register(
|
||||
"FontStyle", typeof (FontStyle),
|
||||
typeof (Series), new PropertyMetadata(FontStyles.Normal, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets labels font style
|
||||
/// </summary>
|
||||
public FontStyle FontStyle
|
||||
{
|
||||
get { return (FontStyle)GetValue(FontStyleProperty); }
|
||||
set { SetValue(FontStyleProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font stretch property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty FontStretchProperty = DependencyProperty.Register(
|
||||
"FontStretch", typeof (FontStretch),
|
||||
typeof (Series), new PropertyMetadata(FontStretches.Normal, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets labels font stretch
|
||||
/// </summary>
|
||||
public FontStretch FontStretch
|
||||
{
|
||||
get { return (FontStretch)GetValue(FontStretchProperty); }
|
||||
set { SetValue(FontStretchProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The foreground property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ForegroundProperty = DependencyProperty.Register(
|
||||
"Foreground", typeof (Brush),
|
||||
typeof (Series), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(55, 71, 79))));
|
||||
/// <summary>
|
||||
/// Gets or sets labels text color.
|
||||
/// </summary>
|
||||
public Brush Foreground
|
||||
{
|
||||
get { return (Brush)GetValue(ForegroundProperty); }
|
||||
set { SetValue(ForegroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stroke dash array property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StrokeDashArrayProperty = DependencyProperty.Register(
|
||||
"StrokeDashArray", typeof(DoubleCollection), typeof(Series),
|
||||
new PropertyMetadata(default(DoubleCollection)));
|
||||
/// <summary>
|
||||
/// Gets or sets the stroke dash array of a series, sue this property to draw dashed strokes
|
||||
/// </summary>
|
||||
public DoubleCollection StrokeDashArray
|
||||
{
|
||||
get { return (DoubleCollection)GetValue(StrokeDashArrayProperty); }
|
||||
set { SetValue(StrokeDashArrayProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The point geometry property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PointGeometryProperty =
|
||||
DependencyProperty.Register("PointGeometry", typeof (Geometry), typeof (Series),
|
||||
new PropertyMetadata(DefaultGeometries.Circle, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the point geometry, this shape will be drawn in the Tooltip, Legend, and if line series in every point also.
|
||||
/// </summary>
|
||||
public Geometry PointGeometry
|
||||
{
|
||||
get { return ((Geometry)GetValue(PointGeometryProperty)); }
|
||||
set { SetValue(PointGeometryProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The scales x at property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ScalesXAtProperty = DependencyProperty.Register(
|
||||
"ScalesXAt", typeof (int), typeof (Series), new PropertyMetadata(default(int), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the axis where series is scaled at, the axis must exist in the collection
|
||||
/// </summary>
|
||||
public int ScalesXAt
|
||||
{
|
||||
get { return (int) GetValue(ScalesXAtProperty); }
|
||||
set { SetValue(ScalesXAtProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The scales y at property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ScalesYAtProperty = DependencyProperty.Register(
|
||||
"ScalesYAt", typeof (int), typeof (Series), new PropertyMetadata(default(int), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the axis where series is scaled at, the axis must exist in the collection
|
||||
/// </summary>
|
||||
public int ScalesYAt
|
||||
{
|
||||
get { return (int) GetValue(ScalesYAtProperty); }
|
||||
set { SetValue(ScalesYAtProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The label point property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelPointProperty = DependencyProperty.Register(
|
||||
"LabelPoint", typeof (Func<ChartPoint, string>), typeof (Series), new PropertyMetadata(default(Func<ChartPoint, string>)));
|
||||
/// <summary>
|
||||
/// Gets or sets the label formatter for the data label and tooltip, this property is set by default according to the series
|
||||
/// </summary>
|
||||
public Func<ChartPoint, string> LabelPoint
|
||||
{
|
||||
get { return (Func<ChartPoint, string>) GetValue(LabelPointProperty); }
|
||||
set { SetValue(LabelPointProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The configuration property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ConfigurationProperty = DependencyProperty.Register(
|
||||
"Configuration", typeof (object), typeof (Series),
|
||||
new PropertyMetadata(default(object), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets series mapper, if this property is set then the library will ignore the SeriesCollection mapper and global mappers.
|
||||
/// </summary>
|
||||
public object Configuration
|
||||
{
|
||||
get { return GetValue(ConfigurationProperty); }
|
||||
set { SetValue(ConfigurationProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal Helpers
|
||||
|
||||
internal ContentControl UpdateLabelContent(DataLabelViewModel content, ContentControl currentControl)
|
||||
{
|
||||
ContentControl control;
|
||||
|
||||
if (currentControl == null)
|
||||
{
|
||||
control = new ContentControl();
|
||||
control.SetBinding(VisibilityProperty,
|
||||
new Binding {Path = new PropertyPath(VisibilityProperty), Source = this});
|
||||
Panel.SetZIndex(control, int.MaxValue - 1);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(control);
|
||||
}
|
||||
else
|
||||
{
|
||||
control = currentControl;
|
||||
}
|
||||
|
||||
control.Content = content;
|
||||
control.ContentTemplate = DataLabelsTemplate;
|
||||
control.FontFamily = FontFamily;
|
||||
control.FontSize = FontSize;
|
||||
control.FontStretch = FontStretch;
|
||||
control.FontStyle = FontStyle;
|
||||
control.FontWeight = FontWeight;
|
||||
control.Foreground = Foreground;
|
||||
|
||||
return control;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Publics
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public virtual IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method runs when the update starts
|
||||
/// </summary>
|
||||
public virtual void OnSeriesUpdateStart()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Erases series
|
||||
/// </summary>
|
||||
public virtual void Erase(bool removeFromView = true)
|
||||
{
|
||||
Values.GetPoints(this).ForEach(p =>
|
||||
{
|
||||
if (p.View != null)
|
||||
p.View.RemoveFromView(Model.Chart);
|
||||
});
|
||||
if (removeFromView) Model.Chart.View.RemoveFromView(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method runs when the update finishes
|
||||
/// </summary>
|
||||
public virtual void OnSeriesUpdatedFinish()
|
||||
{
|
||||
IsFirstDraw = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the series colors if they are not set
|
||||
/// </summary>
|
||||
public virtual void InitializeColors()
|
||||
{
|
||||
var wpfChart = (Chart) Model.Chart.View;
|
||||
|
||||
if (Stroke != null && Fill != null) return;
|
||||
|
||||
var nextColor = wpfChart.GetNextDefaultColor();
|
||||
|
||||
if (Stroke == null)
|
||||
{
|
||||
var strokeBrush = new SolidColorBrush(nextColor);
|
||||
strokeBrush.Freeze();
|
||||
SetValue(StrokeProperty, strokeBrush);
|
||||
}
|
||||
|
||||
if (Fill == null)
|
||||
{
|
||||
var fillBursh = new SolidColorBrush(nextColor) {Opacity = DefaultFillOpacity};
|
||||
fillBursh.Freeze();
|
||||
SetValue(FillProperty, fillBursh);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines special elements to draw according to the series type
|
||||
/// </summary>
|
||||
public virtual void DrawSpecializedElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places specializes items
|
||||
/// </summary>
|
||||
public virtual void PlaceSpecializedElements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the label point formatter.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Func<ChartPoint, string> GetLabelPointFormatter()
|
||||
{
|
||||
if (DesignerProperties.GetIsInDesignMode(this))
|
||||
return x => "Label";
|
||||
|
||||
return LabelPoint;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static void OnValuesInstanceChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
var series = (Series) dependencyObject;
|
||||
|
||||
if (series.Values != series.LastKnownValues && series.LastKnownValues != null)
|
||||
{
|
||||
series.LastKnownValues.GetPoints(series).ForEach(
|
||||
x => { if (x.View != null) x.View.RemoveFromView(series.Model.Chart); });
|
||||
}
|
||||
|
||||
CallChartUpdater()(dependencyObject, dependencyPropertyChangedEventArgs);
|
||||
series.LastKnownValues = series.Values;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls the chart updater.
|
||||
/// </summary>
|
||||
/// <param name="animate">if set to <c>true</c> [animate].</param>
|
||||
/// <returns></returns>
|
||||
protected static PropertyChangedCallback CallChartUpdater(bool animate = false)
|
||||
{
|
||||
return (o, args) =>
|
||||
{
|
||||
var wpfSeries = o as Series;
|
||||
|
||||
if (wpfSeries == null) return;
|
||||
if (wpfSeries.Model == null) return;
|
||||
|
||||
if (wpfSeries.Model.Chart != null) wpfSeries.Model.Chart.Updater.Run(animate);
|
||||
};
|
||||
}
|
||||
|
||||
private Visibility? PreviousVisibility { get; set; }
|
||||
|
||||
private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (Model.Chart == null || PreviousVisibility == Visibility) return;
|
||||
|
||||
PreviousVisibility = Visibility;
|
||||
|
||||
if (PreviousVisibility != null) Model.Chart.Updater.Run(false, false);
|
||||
|
||||
if (Visibility == Visibility.Collapsed || Visibility == Visibility.Hidden)
|
||||
{
|
||||
Erase(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static IChartValues GetValuesForDesigner()
|
||||
{
|
||||
var r = new Random();
|
||||
|
||||
var gvt = Type.GetType("LiveCharts.Geared.GearedValues`1, LiveCharts.Geared");
|
||||
if (gvt != null) gvt = gvt.MakeGenericType(typeof(ObservableValue));
|
||||
|
||||
var obj = gvt != null
|
||||
? (IChartValues) Activator.CreateInstance(gvt)
|
||||
: new ChartValues<ObservableValue>();
|
||||
|
||||
obj.Add(new ObservableValue(r.Next(0, 100)));
|
||||
obj.Add(new ObservableValue(r.Next(0, 100)));
|
||||
obj.Add(new ObservableValue(r.Next(0, 100)));
|
||||
obj.Add(new ObservableValue(r.Next(0, 100)));
|
||||
obj.Add(new ObservableValue(r.Next(0, 100)));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
#region Obsoletes
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
176
Others/Live-Charts-master/WpfView/StackedAreaSeries.cs
Normal file
176
Others/Live-Charts-master/WpfView/StackedAreaSeries.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The stacked area compares trends and percentage, add this series to a cartesian chart
|
||||
/// </summary>
|
||||
/// <seealso cref="LiveCharts.Wpf.LineSeries" />
|
||||
/// <seealso cref="LiveCharts.Definitions.Series.IStackedAreaSeriesView" />
|
||||
public class StackedAreaSeries : LineSeries, IStackedAreaSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of StackedAreaSeries class
|
||||
/// </summary>
|
||||
public StackedAreaSeries()
|
||||
{
|
||||
Model = new StackedAreaAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of StackedAreaSeries class, with a given mapper
|
||||
/// </summary>
|
||||
public StackedAreaSeries(object configuration)
|
||||
{
|
||||
Model = new StackedAreaAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The stack mode property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StackModeProperty = DependencyProperty.Register(
|
||||
"StackMode", typeof(StackMode), typeof(StackedAreaSeries),
|
||||
new PropertyMetadata(default(StackMode), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the series stacked mode, values or percentage
|
||||
/// </summary>
|
||||
public StackMode StackMode
|
||||
{
|
||||
get { return (StackMode)GetValue(StackModeProperty); }
|
||||
set { SetValue(StackModeProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// This method runs when the update starts
|
||||
/// </summary>
|
||||
public override void OnSeriesUpdateStart()
|
||||
{
|
||||
ActiveSplitters = 0;
|
||||
|
||||
if (SplittersCollector == int.MaxValue - 1)
|
||||
{
|
||||
//just in case!
|
||||
Splitters.ForEach(s => s.SplitterCollectorIndex = 0);
|
||||
SplittersCollector = 0;
|
||||
}
|
||||
|
||||
SplittersCollector++;
|
||||
|
||||
if (Figure != null && Values != null)
|
||||
{
|
||||
var xIni = ChartFunctions.ToDrawMargin(Values.GetTracker(this).XLimit.Min, AxisOrientation.X, Model.Chart, ScalesXAt);
|
||||
|
||||
if (Model.Chart.View.DisableAnimations)
|
||||
Figure.StartPoint = new Point(xIni, Model.Chart.DrawMargin.Height);
|
||||
else
|
||||
Figure.BeginAnimation(PathFigure.StartPointProperty,
|
||||
new PointAnimation(new Point(xIni, Model.Chart.DrawMargin.Height),
|
||||
Model.Chart.View.AnimationsSpeed));
|
||||
}
|
||||
|
||||
if (IsPathInitialized)
|
||||
{
|
||||
Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(Path);
|
||||
Path.Stroke = Stroke;
|
||||
Path.StrokeThickness = StrokeThickness;
|
||||
Path.Fill = Fill;
|
||||
Path.Visibility = Visibility;
|
||||
Path.StrokeDashArray = StrokeDashArray;
|
||||
return;
|
||||
}
|
||||
|
||||
IsPathInitialized = true;
|
||||
|
||||
Path = new Path
|
||||
{
|
||||
Stroke = Stroke,
|
||||
StrokeThickness = StrokeThickness,
|
||||
Fill = Fill,
|
||||
Visibility = Visibility,
|
||||
StrokeDashArray = StrokeDashArray
|
||||
};
|
||||
|
||||
var geometry = new PathGeometry();
|
||||
Figure = new PathFigure();
|
||||
geometry.Figures.Add(Figure);
|
||||
Path.Data = geometry;
|
||||
Model.Chart.View.AddToDrawMargin(Path);
|
||||
|
||||
var x = ChartFunctions.ToDrawMargin(ActualValues.GetTracker(this).XLimit.Min, AxisOrientation.X, Model.Chart, ScalesXAt);
|
||||
Figure.StartPoint = new Point(x, Model.Chart.DrawMargin.Height);
|
||||
|
||||
var i = Model.Chart.View.Series.IndexOf(this);
|
||||
Panel.SetZIndex(Path, Model.Chart.View.Series.Count - i);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(LineSmoothnessProperty, .7d);
|
||||
SetCurrentValue(PointGeometrySizeProperty, 0d);
|
||||
SetCurrentValue(PointForegroundProperty, Brushes.White);
|
||||
SetCurrentValue(ForegroundProperty, new SolidColorBrush(Color.FromRgb(229, 229, 229)));
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
DefaultFillOpacity = 1;
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
Splitters = new List<LineSegmentSplitter>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
218
Others/Live-Charts-master/WpfView/StackedColumnSeries.cs
Normal file
218
Others/Live-Charts-master/WpfView/StackedColumnSeries.cs
Normal file
@@ -0,0 +1,218 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The stacked column series compares the proportion of every series in a point
|
||||
/// </summary>
|
||||
public class StackedColumnSeries : Series, IStackedColumnSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of StackedColumnSeries class
|
||||
/// </summary>
|
||||
public StackedColumnSeries()
|
||||
{
|
||||
Model = new StackedColumnAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of StackedColumnSeries class, with a given mapper
|
||||
/// </summary>
|
||||
public StackedColumnSeries(object configuration)
|
||||
{
|
||||
Model = new StackedColumnAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The maximum column width property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxColumnWidthProperty = DependencyProperty.Register(
|
||||
"MaxColumnWidth", typeof (double), typeof (StackedColumnSeries), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum width of a column, any column will be capped at this value
|
||||
/// </summary>
|
||||
public double MaxColumnWidth
|
||||
{
|
||||
get { return (double) GetValue(MaxColumnWidthProperty); }
|
||||
set { SetValue(MaxColumnWidthProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The column padding property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ColumnPaddingProperty = DependencyProperty.Register(
|
||||
"ColumnPadding", typeof (double), typeof (StackedColumnSeries), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets the padding between every column in this series
|
||||
/// </summary>
|
||||
public double ColumnPadding
|
||||
{
|
||||
get { return (double) GetValue(ColumnPaddingProperty); }
|
||||
set { SetValue(ColumnPaddingProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stack mode property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StackModeProperty = DependencyProperty.Register(
|
||||
"StackMode", typeof (StackMode), typeof (StackedColumnSeries), new PropertyMetadata(default(StackMode)));
|
||||
/// <summary>
|
||||
/// Gets or sets stacked mode, values or percentage
|
||||
/// </summary>
|
||||
public StackMode StackMode
|
||||
{
|
||||
get { return (StackMode) GetValue(StackModeProperty); }
|
||||
set { SetValue(StackModeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The labels position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelsPositionProperty = DependencyProperty.Register(
|
||||
"LabelsPosition", typeof(BarLabelPosition), typeof(StackedColumnSeries),
|
||||
new PropertyMetadata(BarLabelPosition.Parallel, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets where the label is placed
|
||||
/// </summary>
|
||||
public BarLabelPosition LabelsPosition
|
||||
{
|
||||
get { return (BarLabelPosition)GetValue(LabelsPositionProperty); }
|
||||
set { SetValue(LabelsPositionProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (ColumnPointView) point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new ColumnPointView
|
||||
{
|
||||
IsNew = true,
|
||||
Rectangle = new Rectangle(),
|
||||
Data = new CoreRectangle()
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Rectangle);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
pbv.Rectangle.Fill = Fill;
|
||||
pbv.Rectangle.StrokeThickness = StrokeThickness;
|
||||
pbv.Rectangle.Stroke = Stroke;
|
||||
pbv.Rectangle.StrokeDashArray = StrokeDashArray;
|
||||
pbv.Rectangle.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.Rectangle, Panel.GetZIndex(this));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
pbv.LabelPosition = LabelsPosition;
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
SetCurrentValue(MaxColumnWidthProperty, 35d);
|
||||
SetCurrentValue(ColumnPaddingProperty, 2d);
|
||||
SetCurrentValue(ForegroundProperty, Brushes.White);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
222
Others/Live-Charts-master/WpfView/StackedRowSeries.cs
Normal file
222
Others/Live-Charts-master/WpfView/StackedRowSeries.cs
Normal file
@@ -0,0 +1,222 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The stacked row series compares the proportion of every series in a point
|
||||
/// </summary>
|
||||
public class StackedRowSeries : Series, IStackedRowSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of StackedRow series class
|
||||
/// </summary>
|
||||
public StackedRowSeries()
|
||||
{
|
||||
Model = new StackedRowAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of StackedRow series class, with a given mapper
|
||||
/// </summary>
|
||||
public StackedRowSeries(object configuration)
|
||||
{
|
||||
Model = new StackedRowAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The maximum row height property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxRowHeightProperty = DependencyProperty.Register(
|
||||
"MaxRowHeight", typeof (double), typeof (StackedRowSeries), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum height of row, any row height will be capped at this value.
|
||||
/// </summary>
|
||||
public double MaxRowHeight
|
||||
{
|
||||
get { return (double) GetValue(MaxRowHeightProperty); }
|
||||
set { SetValue(MaxRowHeightProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The row padding property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RowPaddingProperty = DependencyProperty.Register(
|
||||
"RowPadding", typeof (double), typeof (StackedRowSeries), new PropertyMetadata(default(double)));
|
||||
/// <summary>
|
||||
/// Gets or sets the padding between each row in the series.
|
||||
/// </summary>
|
||||
public double RowPadding
|
||||
{
|
||||
get { return (double) GetValue(RowPaddingProperty); }
|
||||
set { SetValue(RowPaddingProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The stack mode property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StackModeProperty = DependencyProperty.Register(
|
||||
"StackMode", typeof (StackMode), typeof (StackedRowSeries), new PropertyMetadata(default(StackMode)));
|
||||
/// <summary>
|
||||
/// Gets or sets the stacked mode, values or percentage.
|
||||
/// </summary>
|
||||
public StackMode StackMode
|
||||
{
|
||||
get { return (StackMode) GetValue(StackModeProperty); }
|
||||
set { SetValue(StackModeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The labels position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelsPositionProperty = DependencyProperty.Register(
|
||||
"LabelsPosition", typeof(BarLabelPosition), typeof(StackedRowSeries),
|
||||
new PropertyMetadata(BarLabelPosition.Parallel, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets where the label is placed
|
||||
/// </summary>
|
||||
public BarLabelPosition LabelsPosition
|
||||
{
|
||||
get { return (BarLabelPosition)GetValue(LabelsPositionProperty); }
|
||||
set { SetValue(LabelsPositionProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (RowPointView) point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new RowPointView
|
||||
{
|
||||
IsNew = true,
|
||||
Rectangle = new Rectangle(),
|
||||
Data = new CoreRectangle()
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Rectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Rectangle);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
pbv.Rectangle.Fill = Fill;
|
||||
pbv.Rectangle.StrokeThickness = StrokeThickness;
|
||||
pbv.Rectangle.Stroke = Stroke;
|
||||
pbv.Rectangle.StrokeDashArray = StrokeDashArray;
|
||||
pbv.Rectangle.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.Rectangle, Panel.GetZIndex(this));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
|
||||
pbv.LabelPosition = LabelsPosition;
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
SetCurrentValue(MaxRowHeightProperty, 35d);
|
||||
SetCurrentValue(RowPaddingProperty, 2d);
|
||||
SetCurrentValue(ForegroundProperty, Brushes.White);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentXAxis.GetFormatter()(x.X);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
294
Others/Live-Charts-master/WpfView/StepLineSeries.cs
Normal file
294
Others/Live-Charts-master/WpfView/StepLineSeries.cs
Normal file
@@ -0,0 +1,294 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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.SeriesAlgorithms;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
using LiveCharts.Wpf.Components;
|
||||
using LiveCharts.Wpf.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The Step line series.
|
||||
/// </summary>
|
||||
public class StepLineSeries : Series, IFondeable, IAreaPoint
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of BubbleSeries class
|
||||
/// </summary>
|
||||
public StepLineSeries()
|
||||
{
|
||||
Model = new StepLineAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of BubbleSeries class using a given mapper
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
public StepLineSeries(object configuration)
|
||||
{
|
||||
Model = new ScatterAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The point geometry size property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PointGeometrySizeProperty = DependencyProperty.Register(
|
||||
"PointGeometrySize", typeof(double), typeof(StepLineSeries),
|
||||
new PropertyMetadata(default(double), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets the point geometry size, increasing this property will make the series points bigger
|
||||
/// </summary>
|
||||
public double PointGeometrySize
|
||||
{
|
||||
get { return (double)GetValue(PointGeometrySizeProperty); }
|
||||
set { SetValue(PointGeometrySizeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The point foreround property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PointForegroundProperty = DependencyProperty.Register(
|
||||
"PointForeground", typeof(Brush), typeof(StepLineSeries),
|
||||
new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the point shape foreground.
|
||||
/// </summary>
|
||||
public Brush PointForeground
|
||||
{
|
||||
get { return (Brush)GetValue(PointForegroundProperty); }
|
||||
set { SetValue(PointForegroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The alternative stroke property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty AlternativeStrokeProperty = DependencyProperty.Register(
|
||||
"AlternativeStroke", typeof (Brush), typeof (StepLineSeries), new PropertyMetadata(default(Brush)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alternative stroke.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The alternative stroke.
|
||||
/// </value>
|
||||
public Brush AlternativeStroke
|
||||
{
|
||||
get { return (Brush) GetValue(AlternativeStrokeProperty); }
|
||||
set { SetValue(AlternativeStrokeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The inverted mode property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty InvertedModeProperty = DependencyProperty.Register(
|
||||
"InvertedMode", typeof(bool), typeof(StepLineSeries), new PropertyMetadata(default(bool), CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the series should be drawn using the inverted mode.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [inverted mode]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool InvertedMode
|
||||
{
|
||||
get { return (bool) GetValue(InvertedModeProperty); }
|
||||
set { SetValue(InvertedModeProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var pbv = (StepLinePointView) point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new StepLinePointView
|
||||
{
|
||||
IsNew = true,
|
||||
Line2 = new Line(),
|
||||
Line1 = new Line()
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Line2);
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Line1);
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Shape);
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Shape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Line2);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Line1);
|
||||
}
|
||||
|
||||
pbv.Line1.StrokeThickness = StrokeThickness;
|
||||
pbv.Line1.Stroke = AlternativeStroke;
|
||||
pbv.Line1.StrokeDashArray = StrokeDashArray;
|
||||
pbv.Line1.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.Line1, Panel.GetZIndex(this));
|
||||
|
||||
pbv.Line2.StrokeThickness = StrokeThickness;
|
||||
pbv.Line2.Stroke = Stroke;
|
||||
pbv.Line2.StrokeDashArray = StrokeDashArray;
|
||||
pbv.Line2.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.Line2, Panel.GetZIndex(this));
|
||||
|
||||
if (PointGeometry != null && Math.Abs(PointGeometrySize) > 0.1 && pbv.Shape == null)
|
||||
{
|
||||
if (PointGeometry != null)
|
||||
{
|
||||
pbv.Shape = new Path
|
||||
{
|
||||
Stretch = Stretch.Fill,
|
||||
StrokeThickness = StrokeThickness
|
||||
};
|
||||
}
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Shape);
|
||||
}
|
||||
|
||||
if (pbv.Shape != null)
|
||||
{
|
||||
pbv.Shape.Fill = PointForeground;
|
||||
pbv.Shape.StrokeThickness = StrokeThickness;
|
||||
pbv.Shape.Stroke = Stroke;
|
||||
pbv.Shape.StrokeDashArray = StrokeDashArray;
|
||||
pbv.Shape.Visibility = Visibility;
|
||||
pbv.Shape.Width = PointGeometrySize;
|
||||
pbv.Shape.Height = PointGeometrySize;
|
||||
pbv.Shape.Data = PointGeometry;
|
||||
Panel.SetZIndex(pbv.Shape, Panel.GetZIndex(this) + 1);
|
||||
|
||||
if (point.Stroke != null) pbv.Shape.Stroke = (Brush) point.Stroke;
|
||||
if (point.Fill != null) pbv.Shape.Fill = (Brush) point.Fill;
|
||||
}
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart) Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (DataLabels)
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the series colors if they are not set
|
||||
/// </summary>
|
||||
public override void InitializeColors()
|
||||
{
|
||||
var wpfChart = (Chart) Model.Chart.View;
|
||||
|
||||
if (Stroke != null && AlternativeStroke != null) return;
|
||||
|
||||
var nextColor = wpfChart.GetNextDefaultColor();
|
||||
|
||||
if (Stroke == null)
|
||||
SetValue(StrokeProperty, new SolidColorBrush(nextColor));
|
||||
if (AlternativeStroke == null)
|
||||
SetValue(AlternativeStrokeProperty, new SolidColorBrush(nextColor));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
/// <summary>
|
||||
/// Gets the point diameter.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public double GetPointDiameter()
|
||||
{
|
||||
return PointGeometrySize/2;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(PointGeometrySizeProperty, 8d);
|
||||
SetCurrentValue(PointForegroundProperty, Brushes.White);
|
||||
SetCurrentValue(StrokeThicknessProperty, 2d);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.15;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
13
Others/Live-Charts-master/WpfView/Themes/Colors/black.xaml
Normal file
13
Others/Live-Charts-master/WpfView/Themes/Colors/black.xaml
Normal file
@@ -0,0 +1,13 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color A="255" R="15" G="15" B="15" />
|
||||
<Color A="255" R="33" G="33" B="33" />
|
||||
<Color A="255" R="48" G="48" B="48" />
|
||||
<Color A="255" R="66" G="66" B="66" />
|
||||
<Color A="255" R="84" G="84" B="84" />
|
||||
</lvc:ColorsCollection>
|
||||
|
||||
</ResourceDictionary>
|
||||
13
Others/Live-Charts-master/WpfView/Themes/Colors/blue.xaml
Normal file
13
Others/Live-Charts-master/WpfView/Themes/Colors/blue.xaml
Normal file
@@ -0,0 +1,13 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color A="255" R="13" G="71" B="161" />
|
||||
<Color A="255" R="25" G="118" B="210" />
|
||||
<Color A="255" R="33" G="150" B="243" />
|
||||
<Color A="255" R="100" G="181" B="246" />
|
||||
<Color A="255" R="187" G="222" B="251" />
|
||||
</lvc:ColorsCollection>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,16 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color A="255" R="33" G="149" B="242" />
|
||||
<Color A="255" R="243" G="67" B="54" />
|
||||
<Color A="255" R="254" G="192" B="7" />
|
||||
<Color A="255" R="96" G="125" B="138" />
|
||||
<Color A="255" R="232" G="30" B="99" />
|
||||
<Color A="255" R="76" G="174" B="80" />
|
||||
<Color A="255" R="63" G="81" B="180" />
|
||||
<Color A="255" R="204" G="219" B="57" />
|
||||
</lvc:ColorsCollection>
|
||||
|
||||
</ResourceDictionary>
|
||||
16
Others/Live-Charts-master/WpfView/Themes/Colors/metro.xaml
Normal file
16
Others/Live-Charts-master/WpfView/Themes/Colors/metro.xaml
Normal file
@@ -0,0 +1,16 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color A="255" R="45" G="137" B="239" />
|
||||
<Color A="255" R="238" G="17" B="17" />
|
||||
<Color A="255" R="255" G="196" B="13" />
|
||||
<Color A="255" R="0" G="171" B="169" />
|
||||
<Color A="255" R="255" G="0" B="151" />
|
||||
<Color A="255" R="0" G="163" B="0" />
|
||||
<Color A="255" R="218" G="83" B="44" />
|
||||
<Color A="255" R="43" G="87" B="151" />
|
||||
</lvc:ColorsCollection>
|
||||
|
||||
</ResourceDictionary>
|
||||
13
Others/Live-Charts-master/WpfView/Themes/Colors/white.xaml
Normal file
13
Others/Live-Charts-master/WpfView/Themes/Colors/white.xaml
Normal file
@@ -0,0 +1,13 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color A="255" R="255" G="255" B="255" />
|
||||
<Color A="255" R="250" G="250" B="250" />
|
||||
<Color A="255" R="245" G="245" B="245" />
|
||||
<Color A="255" R="240" G="240" B="240" />
|
||||
<Color A="255" R="235" G="235" B="235" />
|
||||
</lvc:ColorsCollection>
|
||||
|
||||
</ResourceDictionary>
|
||||
8
Others/Live-Charts-master/WpfView/Themes/Size/l.xaml
Normal file
8
Others/Live-Charts-master/WpfView/Themes/Size/l.xaml
Normal file
@@ -0,0 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:Double x:Key="Size">15</system:Double>
|
||||
|
||||
</ResourceDictionary>
|
||||
8
Others/Live-Charts-master/WpfView/Themes/Size/m.xaml
Normal file
8
Others/Live-Charts-master/WpfView/Themes/Size/m.xaml
Normal file
@@ -0,0 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:Double x:Key="Size">12</system:Double>
|
||||
|
||||
</ResourceDictionary>
|
||||
8
Others/Live-Charts-master/WpfView/Themes/Size/s.xaml
Normal file
8
Others/Live-Charts-master/WpfView/Themes/Size/s.xaml
Normal file
@@ -0,0 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:Double x:Key="Size">10</system:Double>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,9 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:Double x:Key="SeparatorStrokeThickness">2.2</system:Double>
|
||||
<DoubleCollection x:Key="SeparatorStrokeDashArray">4</DoubleCollection>
|
||||
<system:Double x:Key="SeriesStrokeThickness">4.2</system:Double>
|
||||
</ResourceDictionary>
|
||||
10
Others/Live-Charts-master/WpfView/Themes/Weight/light.xaml
Normal file
10
Others/Live-Charts-master/WpfView/Themes/Weight/light.xaml
Normal file
@@ -0,0 +1,10 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:Double x:Key="SeparatorStrokeThickness">1.3</system:Double>
|
||||
<DoubleCollection x:Key="SeparatorStrokeDashArray"></DoubleCollection>
|
||||
<system:Double x:Key="SeriesStrokeThickness">1</system:Double>
|
||||
|
||||
</ResourceDictionary>
|
||||
10
Others/Live-Charts-master/WpfView/Themes/Weight/normal.xaml
Normal file
10
Others/Live-Charts-master/WpfView/Themes/Weight/normal.xaml
Normal file
@@ -0,0 +1,10 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:Double x:Key="SeparatorStrokeThickness">1.8</system:Double>
|
||||
<DoubleCollection x:Key="SeparatorStrokeDashArray">3</DoubleCollection>
|
||||
<system:Double x:Key="SeriesStrokeThickness">3.0</system:Double>
|
||||
|
||||
</ResourceDictionary>
|
||||
54
Others/Live-Charts-master/WpfView/Themes/base.xaml
Normal file
54
Others/Live-Charts-master/WpfView/Themes/base.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf">
|
||||
|
||||
<Style TargetType="lvc:CartesianChart">
|
||||
<Setter Property="AnimationsSpeed" Value="0:0:0.420"></Setter>
|
||||
<Setter Property="SeriesColors" Value="{StaticResource ColorsCollection}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="lvc:Axis">
|
||||
<Setter Property="FontSize" Value="{StaticResource Size}"></Setter>
|
||||
<Setter Property="FontFamily" Value="Calibri"></Setter>
|
||||
<Setter Property="Foreground" Value="#99303030"></Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="lvc:Separator">
|
||||
<Setter Property="StrokeThickness" Value="{StaticResource SeparatorStrokeThickness}"></Setter>
|
||||
<Setter Property="StrokeDashArray" Value="{StaticResource SeparatorStrokeDashArray}"></Setter>
|
||||
<Setter Property="Stroke" Value="#1A303030"></Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="AxisOrientation" Value="X">
|
||||
<Setter Property="IsEnabled" Value="False"></Setter>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="lvc:Series" x:Key="SeriesStyle">
|
||||
<Setter Property="FontFamily" Value="Calibri"></Setter>
|
||||
<Setter Property="FontSize" Value="{StaticResource Size}"></Setter>
|
||||
<Setter Property="StrokeThickness" Value="{StaticResource SeriesStrokeThickness}"></Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="lvc:CandleSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:ColumnSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:HeatSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:LineSeries" BasedOn="{StaticResource SeriesStyle}">
|
||||
<Setter Property="PointGeometrySize" Value="{StaticResource Size}"></Setter>
|
||||
</Style>
|
||||
<Style TargetType="lvc:StepLineSeries" BasedOn="{StaticResource SeriesStyle}">
|
||||
<Setter Property="PointGeometrySize" Value="{StaticResource Size}"></Setter>
|
||||
</Style>
|
||||
<Style TargetType="lvc:VerticalLineSeries" BasedOn="{StaticResource SeriesStyle}">
|
||||
<Setter Property="PointGeometrySize" Value="{StaticResource Size}"></Setter>
|
||||
</Style>
|
||||
<Style TargetType="lvc:OhlcSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:RowSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:ScatterSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:StackedAreaSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:StackedColumnSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:StackedRowSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:VerticalStackedAreaSeries" BasedOn="{StaticResource SeriesStyle}"/>
|
||||
<Style TargetType="lvc:PieSeries" BasedOn="{StaticResource SeriesStyle}"></Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
344
Others/Live-Charts-master/WpfView/VerticalLineSeries.cs
Normal file
344
Others/Live-Charts-master/WpfView/VerticalLineSeries.cs
Normal file
@@ -0,0 +1,344 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Dtos;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Wpf.Charts.Base;
|
||||
using LiveCharts.Wpf.Points;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// The vertical line series is useful to compare trends, this is the inverted version of the LineSeries, this series must be added in a cartesian chart.
|
||||
/// </summary>
|
||||
public class VerticalLineSeries : LineSeries
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes an new instance of VerticalLineSeries class
|
||||
/// </summary>
|
||||
public VerticalLineSeries()
|
||||
{
|
||||
Model = new VerticalLineAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes an new instance of VerticalLineSeries class, with a given mapper
|
||||
/// </summary>
|
||||
public VerticalLineSeries(object configuration)
|
||||
{
|
||||
Model = new VerticalLineAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// This method runs when the update starts
|
||||
/// </summary>
|
||||
public override void OnSeriesUpdateStart()
|
||||
{
|
||||
ActiveSplitters = 0;
|
||||
|
||||
if (SplittersCollector == int.MaxValue - 1)
|
||||
{
|
||||
//just in case!
|
||||
Splitters.ForEach(s => s.SplitterCollectorIndex = 0);
|
||||
SplittersCollector = 0;
|
||||
}
|
||||
|
||||
SplittersCollector++;
|
||||
|
||||
if (IsPathInitialized)
|
||||
{
|
||||
Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(Path);
|
||||
Path.Stroke = Stroke;
|
||||
Path.StrokeThickness = StrokeThickness;
|
||||
Path.Fill = Fill;
|
||||
Path.Visibility = Visibility;
|
||||
Path.StrokeDashArray = StrokeDashArray;
|
||||
Panel.SetZIndex(Path, Panel.GetZIndex(this));
|
||||
return;
|
||||
}
|
||||
|
||||
IsPathInitialized = true;
|
||||
|
||||
Path = new Path
|
||||
{
|
||||
Stroke = Stroke,
|
||||
StrokeThickness = StrokeThickness,
|
||||
Fill = Fill,
|
||||
Visibility = Visibility,
|
||||
StrokeDashArray = StrokeDashArray
|
||||
};
|
||||
|
||||
Panel.SetZIndex(Path, Panel.GetZIndex(this));
|
||||
|
||||
var geometry = new PathGeometry();
|
||||
Figure = new PathFigure();
|
||||
geometry.Figures.Add(Figure);
|
||||
Path.Data = geometry;
|
||||
|
||||
Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(Path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view of a given point
|
||||
/// </summary>
|
||||
/// <param name="point"></param>
|
||||
/// <param name="label"></param>
|
||||
/// <returns></returns>
|
||||
public override IChartPointView GetPointView(ChartPoint point, string label)
|
||||
{
|
||||
var mhr = PointGeometrySize < 10 ? 10 : PointGeometrySize;
|
||||
|
||||
var pbv = (VerticalBezierPointView) point.View;
|
||||
|
||||
if (pbv == null)
|
||||
{
|
||||
pbv = new VerticalBezierPointView
|
||||
{
|
||||
Segment = new BezierSegment(),
|
||||
Container = Figure,
|
||||
IsNew = true
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.IsNew = false;
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.Shape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.HoverShape);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = Brushes.Transparent,
|
||||
StrokeThickness = 0,
|
||||
Width = mhr,
|
||||
Height = mhr
|
||||
};
|
||||
|
||||
Panel.SetZIndex(pbv.HoverShape, int.MaxValue);
|
||||
|
||||
var wpfChart = (Chart)Model.Chart.View;
|
||||
wpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (PointGeometry != null && Math.Abs(PointGeometrySize) > 0.1 && pbv.Shape == null)
|
||||
{
|
||||
if (PointGeometry != null)
|
||||
{
|
||||
pbv.Shape = new Path
|
||||
{
|
||||
Stretch = Stretch.Fill,
|
||||
StrokeThickness = StrokeThickness
|
||||
};
|
||||
}
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Shape);
|
||||
}
|
||||
|
||||
if (pbv.Shape != null)
|
||||
{
|
||||
pbv.Shape.Fill = PointForeground;
|
||||
pbv.Shape.Stroke = Stroke;
|
||||
pbv.Shape.StrokeThickness = StrokeThickness;
|
||||
pbv.Shape.Width = PointGeometrySize;
|
||||
pbv.Shape.Height = PointGeometrySize;
|
||||
pbv.Shape.Data = PointGeometry;
|
||||
pbv.Shape.Visibility = Visibility;
|
||||
Panel.SetZIndex(pbv.Shape, Panel.GetZIndex(this) + 1);
|
||||
|
||||
if (point.Stroke != null) pbv.Shape.Stroke = (Brush)point.Stroke;
|
||||
if (point.Fill != null) pbv.Shape.Fill = (Brush)point.Fill;
|
||||
}
|
||||
|
||||
if (DataLabels )
|
||||
{
|
||||
pbv.DataLabel = UpdateLabelContent(new DataLabelViewModel
|
||||
{
|
||||
FormattedText = label,
|
||||
Instance = point.Instance
|
||||
}, pbv.DataLabel);
|
||||
}
|
||||
|
||||
return pbv;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Starts the segment.
|
||||
/// </summary>
|
||||
/// <param name="atIndex">At index.</param>
|
||||
/// <param name="location">The location.</param>
|
||||
public override void StartSegment(int atIndex, CorePoint location)
|
||||
{
|
||||
if (Splitters.Count <= ActiveSplitters)
|
||||
Splitters.Add(new LineSegmentSplitter { IsNew = true });
|
||||
|
||||
var splitter = Splitters[ActiveSplitters];
|
||||
splitter.SplitterCollectorIndex = SplittersCollector;
|
||||
|
||||
ActiveSplitters++;
|
||||
var animSpeed = Model.Chart.View.AnimationsSpeed;
|
||||
var noAnim = Model.Chart.View.DisableAnimations;
|
||||
|
||||
var areaLimit = ChartFunctions.ToDrawMargin(double.IsNaN(AreaLimit)
|
||||
? Model.Chart.AxisX[ScalesXAt].FirstSeparator
|
||||
: AreaLimit, AxisOrientation.X, Model.Chart, ScalesXAt);
|
||||
|
||||
if (Values != null && atIndex == 0)
|
||||
{
|
||||
if (Model.Chart.View.DisableAnimations || IsNew)
|
||||
Figure.StartPoint = new Point(areaLimit, location.Y);
|
||||
else
|
||||
Figure.BeginAnimation(PathFigure.StartPointProperty,
|
||||
new PointAnimation(new Point(areaLimit, location.Y), animSpeed));
|
||||
|
||||
IsNew = false;
|
||||
}
|
||||
|
||||
if (atIndex != 0)
|
||||
{
|
||||
Figure.Segments.Remove(splitter.Bottom);
|
||||
|
||||
if (splitter.IsNew)
|
||||
{
|
||||
splitter.Bottom.Point = new Point(Model.Chart.DrawMargin.Width, location.Y);
|
||||
splitter.Left.Point = new Point(Model.Chart.DrawMargin.Width, location.Y);
|
||||
}
|
||||
|
||||
if (noAnim)
|
||||
splitter.Bottom.Point = new Point(Model.Chart.DrawMargin.Width, location.Y);
|
||||
else
|
||||
splitter.Bottom.BeginAnimation(LineSegment.PointProperty,
|
||||
new PointAnimation(new Point(Model.Chart.DrawMargin.Width, location.Y), animSpeed));
|
||||
Figure.Segments.Insert(atIndex, splitter.Bottom);
|
||||
|
||||
Figure.Segments.Remove(splitter.Left);
|
||||
if (noAnim)
|
||||
splitter.Left.Point = location.AsPoint();
|
||||
else
|
||||
splitter.Left.BeginAnimation(LineSegment.PointProperty,
|
||||
new PointAnimation(location.AsPoint(), animSpeed));
|
||||
Figure.Segments.Insert(atIndex + 1, splitter.Left);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (splitter.IsNew)
|
||||
{
|
||||
splitter.Bottom.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
|
||||
splitter.Left.Point = new Point(location.X, Model.Chart.DrawMargin.Height);
|
||||
}
|
||||
|
||||
Figure.Segments.Remove(splitter.Left);
|
||||
if (Model.Chart.View.DisableAnimations)
|
||||
splitter.Left.Point = location.AsPoint();
|
||||
else
|
||||
splitter.Left.BeginAnimation(LineSegment.PointProperty,
|
||||
new PointAnimation(location.AsPoint(), animSpeed));
|
||||
Figure.Segments.Insert(atIndex, splitter.Left);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends the segment.
|
||||
/// </summary>
|
||||
/// <param name="atIndex">At index.</param>
|
||||
/// <param name="location">The location.</param>
|
||||
public override void EndSegment(int atIndex, CorePoint location)
|
||||
{
|
||||
var splitter = Splitters[ActiveSplitters - 1];
|
||||
|
||||
var animSpeed = Model.Chart.View.AnimationsSpeed;
|
||||
var noAnim = Model.Chart.View.DisableAnimations;
|
||||
|
||||
var areaLimit = ChartFunctions.ToDrawMargin(double.IsNaN(AreaLimit)
|
||||
? Model.Chart.AxisX[ScalesXAt].FirstSeparator
|
||||
: AreaLimit, AxisOrientation.X, Model.Chart, ScalesXAt);
|
||||
|
||||
var uw = Model.Chart.AxisY[ScalesYAt].EvaluatesUnitWidth
|
||||
? ChartFunctions.GetUnitWidth(AxisOrientation.Y, Model.Chart, ScalesYAt) / 2
|
||||
: 0;
|
||||
location.Y += uw;
|
||||
|
||||
if (splitter.IsNew)
|
||||
{
|
||||
splitter.Right.Point = new Point(0, location.Y);
|
||||
}
|
||||
|
||||
Figure.Segments.Remove(splitter.Right);
|
||||
if (noAnim)
|
||||
splitter.Right.Point = new Point(areaLimit, location.Y);
|
||||
else
|
||||
splitter.Right.BeginAnimation(LineSegment.PointProperty,
|
||||
new PointAnimation(new Point(areaLimit, location.Y), animSpeed));
|
||||
Figure.Segments.Insert(atIndex, splitter.Right);
|
||||
|
||||
splitter.IsNew = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(LineSmoothnessProperty, .7d);
|
||||
SetCurrentValue(PointGeometrySizeProperty, 8d);
|
||||
SetCurrentValue(PointForegroundProperty, Brushes.White);
|
||||
SetCurrentValue(StrokeThicknessProperty, 2d);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentXAxis.GetFormatter()(x.X);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.15;
|
||||
Splitters = new List<LineSegmentSplitter>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
173
Others/Live-Charts-master/WpfView/VerticalStackedAreaSeries.cs
Normal file
173
Others/Live-Charts-master/WpfView/VerticalStackedAreaSeries.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares trend and proportion, this series must be added in a cartesian chart.
|
||||
/// </summary>
|
||||
public class VerticalStackedAreaSeries : VerticalLineSeries, IVerticalStackedAreaSeriesView
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of VerticalStackedAreaSeries class
|
||||
/// </summary>
|
||||
public VerticalStackedAreaSeries()
|
||||
{
|
||||
Model = new VerticalStackedAreaAlgorithm(this);
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of VerticalStackedAreaSeries class, with a given mapper
|
||||
/// </summary>
|
||||
public VerticalStackedAreaSeries(object configuration)
|
||||
{
|
||||
Model = new VerticalStackedAreaAlgorithm(this);
|
||||
Configuration = configuration;
|
||||
InitializeDefuaults();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// The stack mode property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StackModeProperty = DependencyProperty.Register(
|
||||
"StackMode", typeof (StackMode), typeof (VerticalStackedAreaSeries), new PropertyMetadata(default(StackMode)));
|
||||
/// <summary>
|
||||
/// Gets or sets the series stack mode, values or percentage
|
||||
/// </summary>
|
||||
public StackMode StackMode
|
||||
{
|
||||
get { return (StackMode) GetValue(StackModeProperty); }
|
||||
set { SetValue(StackModeProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
/// <summary>
|
||||
/// This method runs when the update starts
|
||||
/// </summary>
|
||||
public override void OnSeriesUpdateStart()
|
||||
{
|
||||
ActiveSplitters = 0;
|
||||
|
||||
if (SplittersCollector == int.MaxValue - 1)
|
||||
{
|
||||
//just in case!
|
||||
Splitters.ForEach(s => s.SplitterCollectorIndex = 0);
|
||||
SplittersCollector = 0;
|
||||
}
|
||||
|
||||
SplittersCollector++;
|
||||
|
||||
if (Figure != null && Values != null)
|
||||
{
|
||||
var yIni = ChartFunctions.ToDrawMargin(Values.GetTracker(this).YLimit.Min, AxisOrientation.Y, Model.Chart, ScalesYAt);
|
||||
|
||||
if (Model.Chart.View.DisableAnimations)
|
||||
Figure.StartPoint = new Point(0, yIni);
|
||||
else
|
||||
Figure.BeginAnimation(PathFigure.StartPointProperty,
|
||||
new PointAnimation(new Point(0, yIni),
|
||||
Model.Chart.View.AnimationsSpeed));
|
||||
}
|
||||
|
||||
if (IsPathInitialized)
|
||||
{
|
||||
Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(Path);
|
||||
Path.Stroke = Stroke;
|
||||
Path.StrokeThickness = StrokeThickness;
|
||||
Path.Fill = Fill;
|
||||
Path.Visibility = Visibility;
|
||||
Path.StrokeDashArray = StrokeDashArray;
|
||||
return;
|
||||
}
|
||||
|
||||
IsPathInitialized = true;
|
||||
|
||||
Path = new Path
|
||||
{
|
||||
Stroke = Stroke,
|
||||
StrokeThickness = StrokeThickness,
|
||||
Fill = Fill,
|
||||
Visibility = Visibility,
|
||||
StrokeDashArray = StrokeDashArray
|
||||
};
|
||||
|
||||
Panel.SetZIndex(Path, Panel.GetZIndex(this));
|
||||
|
||||
var geometry = new PathGeometry();
|
||||
Figure = new PathFigure();
|
||||
geometry.Figures.Add(Figure);
|
||||
Path.Data = geometry;
|
||||
Model.Chart.View.AddToDrawMargin(Path);
|
||||
|
||||
var y = ChartFunctions.ToDrawMargin(ActualValues.GetTracker(this).YLimit.Min, AxisOrientation.Y, Model.Chart, ScalesYAt);
|
||||
Figure.StartPoint = new Point(0, y);
|
||||
|
||||
var i = Model.Chart.View.Series.IndexOf(this);
|
||||
Panel.SetZIndex(Path, Model.Chart.View.Series.Count - i);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
SetCurrentValue(LineSmoothnessProperty, .7d);
|
||||
SetCurrentValue(PointGeometrySizeProperty, 0d);
|
||||
SetCurrentValue(PointForegroundProperty, Brushes.White);
|
||||
SetCurrentValue(ForegroundProperty, new SolidColorBrush(Color.FromRgb(229, 229, 229)));
|
||||
SetCurrentValue(StrokeThicknessProperty, 0d);
|
||||
SetCurrentValue(StackModeProperty, StackMode.Values);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentXAxis.GetFormatter()(x.X);
|
||||
SetCurrentValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
Splitters = new List<LineSegmentSplitter>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
186
Others/Live-Charts-master/WpfView/VisualElement.cs
Normal file
186
Others/Live-Charts-master/WpfView/VisualElement.cs
Normal file
@@ -0,0 +1,186 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//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.Animation;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Dtos;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a visual element, a visual element is a UI element that is placed and scaled in the chart.
|
||||
/// </summary>
|
||||
public class VisualElement : FrameworkElement, ICartesianVisualElement
|
||||
{
|
||||
private ChartCore _owner;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// Gets or sets the user interface element.
|
||||
/// </summary>
|
||||
public FrameworkElement UIElement { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the index of the axis in X that owns the element, the axis position must exist.
|
||||
/// </summary>
|
||||
public int AxisX { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the index of the axis in Y that owns the element, the axis position must exist.
|
||||
/// </summary>
|
||||
public int AxisY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The x property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty XProperty = DependencyProperty.Register(
|
||||
"X", typeof (double), typeof (VisualElement),
|
||||
new PropertyMetadata(default(double), PropertyChangedCallback));
|
||||
/// <summary>
|
||||
/// Gets or sets the X value of the UiElement
|
||||
/// </summary>
|
||||
public double X
|
||||
{
|
||||
get { return (double) GetValue(XProperty); }
|
||||
set { SetValue(XProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The y property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty YProperty = DependencyProperty.Register(
|
||||
"Y", typeof (double), typeof (VisualElement),
|
||||
new PropertyMetadata(default(double), PropertyChangedCallback));
|
||||
/// <summary>
|
||||
/// Gets or sets the Y value of the UiElement
|
||||
/// </summary>
|
||||
public double Y
|
||||
{
|
||||
get { return (double) GetValue(YProperty); }
|
||||
set { SetValue(YProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the or move.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// </exception>
|
||||
public void AddOrMove(ChartCore chart)
|
||||
{
|
||||
if (chart == null || UIElement == null) return;
|
||||
if (!chart.AreComponentsLoaded) return;
|
||||
|
||||
if (UIElement.Parent == null)
|
||||
{
|
||||
chart.View.AddToDrawMargin(UIElement);
|
||||
Panel.SetZIndex(UIElement, 1000);
|
||||
}
|
||||
|
||||
var coordinate = new CorePoint(ChartFunctions.ToDrawMargin(X, AxisOrientation.X, chart, AxisX),
|
||||
ChartFunctions.ToDrawMargin(Y, AxisOrientation.Y, chart.View.Model, AxisY));
|
||||
|
||||
var wpfChart = (CartesianChart) chart.View;
|
||||
|
||||
var uw = new CorePoint(
|
||||
wpfChart.AxisX[AxisX].Model.EvaluatesUnitWidth
|
||||
? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart, AxisX)/2
|
||||
: 0,
|
||||
wpfChart.AxisY[AxisY].Model.EvaluatesUnitWidth
|
||||
? ChartFunctions.GetUnitWidth(AxisOrientation.Y, chart, AxisY)/2
|
||||
: 0);
|
||||
|
||||
coordinate += uw;
|
||||
|
||||
UIElement.UpdateLayout();
|
||||
|
||||
switch (VerticalAlignment)
|
||||
{
|
||||
case VerticalAlignment.Top:
|
||||
coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight);
|
||||
break;
|
||||
case VerticalAlignment.Center:
|
||||
coordinate = new CorePoint(coordinate.X, coordinate.Y - UIElement.ActualHeight / 2);
|
||||
break;
|
||||
case VerticalAlignment.Bottom:
|
||||
coordinate = new CorePoint(coordinate.X, coordinate.Y);
|
||||
break;
|
||||
case VerticalAlignment.Stretch:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
switch (HorizontalAlignment)
|
||||
{
|
||||
case HorizontalAlignment.Left:
|
||||
coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth, coordinate.Y);
|
||||
break;
|
||||
case HorizontalAlignment.Center:
|
||||
coordinate = new CorePoint(coordinate.X - UIElement.ActualWidth / 2, coordinate.Y);
|
||||
break;
|
||||
case HorizontalAlignment.Right:
|
||||
coordinate = new CorePoint(coordinate.X, coordinate.Y);
|
||||
break;
|
||||
case HorizontalAlignment.Stretch:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
if (chart.View.DisableAnimations)
|
||||
{
|
||||
Canvas.SetLeft(UIElement, coordinate.X);
|
||||
Canvas.SetTop(UIElement, coordinate.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (double.IsNaN(Canvas.GetLeft(UIElement)))
|
||||
{
|
||||
Canvas.SetLeft(UIElement, coordinate.X);
|
||||
Canvas.SetTop(UIElement, coordinate.Y);
|
||||
}
|
||||
UIElement.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(coordinate.X, wpfChart.AnimationsSpeed));
|
||||
UIElement.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(coordinate.Y, wpfChart.AnimationsSpeed));
|
||||
}
|
||||
|
||||
_owner = chart;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified chart.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
public void Remove(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromDrawMargin(UIElement);
|
||||
}
|
||||
|
||||
private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
var element = (VisualElement) dependencyObject;
|
||||
if (element._owner != null) element.AddOrMove(element._owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
148
Others/Live-Charts-master/WpfView/WindowAxis.cs
Normal file
148
Others/Live-Charts-master/WpfView/WindowAxis.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
//The MIT License(MIT)
|
||||
|
||||
//Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors
|
||||
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Wpf.Components;
|
||||
|
||||
namespace LiveCharts.Wpf
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="LiveCharts.Wpf.Axis" />
|
||||
/// <seealso cref="LiveCharts.Definitions.Charts.IWindowAxisView" />
|
||||
public class WindowAxis : Axis, IWindowAxisView
|
||||
{
|
||||
public static readonly DependencyProperty WindowsProperty = DependencyProperty.Register("Windows", typeof(AxisWindowCollection), typeof(WindowAxis),new PropertyMetadata(default(AxisWindowCollection)));
|
||||
public static readonly DependencyProperty SelectedWindowProperty = DependencyProperty.Register("SelectedWindow", typeof(IAxisWindow), typeof(WindowAxis), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty HeaderFontWeightProperty = DependencyProperty.Register("HeaderFontWeight", typeof(FontWeight), typeof(WindowAxis), new PropertyMetadata(FontWeights.ExtraBold));
|
||||
public static readonly DependencyProperty HeaderForegroundProperty = DependencyProperty.Register("HeaderForeground", typeof(Brush), typeof(WindowAxis), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(130, 130, 130))));
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public AxisWindowCollection Windows
|
||||
{
|
||||
get { return (AxisWindowCollection)GetValue(WindowsProperty); }
|
||||
set { SetValue(WindowsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IAxisWindow SelectedWindow
|
||||
{
|
||||
get { return (IAxisWindow)GetValue(SelectedWindowProperty); }
|
||||
set { SetValue(SelectedWindowProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public WindowAxis()
|
||||
{
|
||||
SetCurrentValue(WindowsProperty, new AxisWindowCollection());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets labels font weight
|
||||
/// </summary>
|
||||
public FontWeight HeaderFontWeight
|
||||
{
|
||||
get { return (FontWeight)GetValue(HeaderFontWeightProperty); }
|
||||
set { SetValue(HeaderFontWeightProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets labels text color.
|
||||
/// </summary>
|
||||
public Brush HeaderForeground
|
||||
{
|
||||
get { return (Brush)GetValue(HeaderForegroundProperty); }
|
||||
set { SetValue(HeaderForegroundProperty, value); }
|
||||
}
|
||||
|
||||
public override AxisCore AsCoreElement(ChartCore chart, AxisOrientation source)
|
||||
{
|
||||
if (Model == null) Model = new WindowAxisCore(this);
|
||||
Model.ShowLabels = ShowLabels;
|
||||
Model.Chart = chart;
|
||||
Model.IsMerged = IsMerged;
|
||||
Model.Labels = Labels;
|
||||
Model.LabelFormatter = LabelFormatter;
|
||||
Model.MaxValue = MaxValue;
|
||||
Model.MinValue = MinValue;
|
||||
Model.Title = Title;
|
||||
Model.Position = Position;
|
||||
Model.Separator = Separator.AsCoreElement(Model, source);
|
||||
Model.DisableAnimations = DisableAnimations;
|
||||
Model.Sections = Sections.Select(x => x.AsCoreElement(Model, source)).ToList();
|
||||
((WindowAxisCore) Model).Windows = Windows.ToList();
|
||||
return Model;
|
||||
}
|
||||
|
||||
public override void RenderSeparator(SeparatorElementCore model, ChartCore chart)
|
||||
{
|
||||
base.RenderSeparator(model, chart);
|
||||
|
||||
// Review whetehr hould we not implement this with a trigger instead of resetting property bindings
|
||||
var element = (AxisSeparatorElement)model.View;
|
||||
if (((DateSeparatorElementCore)model).IsHeader)
|
||||
{
|
||||
element.TextBlock.SetBinding(TextBlock.FontWeightProperty, new Binding
|
||||
{
|
||||
Path = new PropertyPath(HeaderFontWeightProperty),
|
||||
Source = this
|
||||
});
|
||||
element.TextBlock.SetBinding(TextBlock.ForegroundProperty, new Binding
|
||||
{
|
||||
Path = new PropertyPath(HeaderForegroundProperty),
|
||||
Source = this
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
element.TextBlock.SetBinding(TextBlock.FontWeightProperty, new Binding
|
||||
{
|
||||
Path = new PropertyPath(FontWeightProperty),
|
||||
Source = this
|
||||
});
|
||||
element.TextBlock.SetBinding(TextBlock.ForegroundProperty, new Binding
|
||||
{
|
||||
Path = new PropertyPath(ForegroundProperty),
|
||||
Source = this
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSelectedWindow(IAxisWindow window)
|
||||
{
|
||||
SetCurrentValue(SelectedWindowProperty, window);
|
||||
}
|
||||
}
|
||||
}
|
||||
246
Others/Live-Charts-master/WpfView/WpfView.csproj
Normal file
246
Others/Live-Charts-master/WpfView/WpfView.csproj
Normal file
@@ -0,0 +1,246 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{4D253423-AE05-47F6-A59D-9162EC0BB1F2}</ProjectGuid>
|
||||
<OutputType>library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LiveCharts.Wpf</RootNamespace>
|
||||
<AssemblyName>LiveCharts.Wpf</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkProfile />
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.0' ">NET40</DefineConstants>
|
||||
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.5' ">NET45</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Wpf.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.0' ">NET40</DefineConstants>
|
||||
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.5' ">NET45</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Wpf.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>sign.pfx</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DelaySign>false</DelaySign>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AngularGauge.cs" />
|
||||
<Compile Include="AngularSection.cs" />
|
||||
<Compile Include="AxisWindowCollection.cs" />
|
||||
<Compile Include="ColorsCollection.cs" />
|
||||
<Compile Include="Components\DefaultXamlReader.cs" />
|
||||
<Compile Include="Components\IFondeable.cs" />
|
||||
<Compile Include="Components\ThreadAccess.cs" />
|
||||
<Compile Include="DateAxis.cs" />
|
||||
<Compile Include="FinancialColoringRule.cs" />
|
||||
<Compile Include="IChartLegend.cs" />
|
||||
<Compile Include="IChartTooltip.cs" />
|
||||
<Compile Include="LogarithmicAxis.cs" />
|
||||
<Compile Include="ScatterSeries.cs" />
|
||||
<Compile Include="DefaultGeoMapTooltip.xaml.cs">
|
||||
<DependentUpon>DefaultGeoMapTooltip.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DefaultGeometry.cs" />
|
||||
<Compile Include="HeatColorRange.xaml.cs">
|
||||
<DependentUpon>HeatColorRange.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CandleSeries.cs" />
|
||||
<Compile Include="Maps\MapResolver.cs" />
|
||||
<Compile Include="Points\HeatPoint.cs" />
|
||||
<Compile Include="Points\CandlePointView.cs" />
|
||||
<Compile Include="Points\StepLinePointView.cs" />
|
||||
<Compile Include="SectionsCollection.cs" />
|
||||
<Compile Include="AxesCollection.cs" />
|
||||
<Compile Include="Axis.cs" />
|
||||
<Compile Include="AxisSection.cs" />
|
||||
<Compile Include="Gauge.cs" />
|
||||
<Compile Include="PieChart.cs" />
|
||||
<Compile Include="Components\ChartUpdater.cs" />
|
||||
<Compile Include="Components\AxisSeparatorElement.cs" />
|
||||
<Compile Include="Charts\Base\Chart.cs" />
|
||||
<Compile Include="Converters\TypeConverters.cs" />
|
||||
<Compile Include="DefaultLegend.xaml.cs">
|
||||
<DependentUpon>DefaultLegend.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DefaultTooltip.xaml.cs">
|
||||
<DependentUpon>DefaultTooltip.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Points\PiePointView.cs" />
|
||||
<Compile Include="Points\OhlcPointView.cs" />
|
||||
<Compile Include="Points\ScatterPointView.cs" />
|
||||
<Compile Include="Points\PieSlice.cs" />
|
||||
<Compile Include="Points\RowPointView.cs" />
|
||||
<Compile Include="Points\ColumnPointView.cs" />
|
||||
<Compile Include="Points\VerticalBezierPointView.cs" />
|
||||
<Compile Include="HeatSeries.cs" />
|
||||
<Compile Include="PieSeries.cs" />
|
||||
<Compile Include="OhlcSeries.cs" />
|
||||
<Compile Include="StackedAreaSeries.cs" />
|
||||
<Compile Include="StackedRowSeries.cs" />
|
||||
<Compile Include="StackedColumnSeries.cs" />
|
||||
<Compile Include="RowSeries.cs" />
|
||||
<Compile Include="ColumnSeries.cs" />
|
||||
<Compile Include="StepLineSeries.cs" />
|
||||
<Compile Include="VerticalStackedAreaSeries.cs" />
|
||||
<Compile Include="VerticalLineSeries.cs" />
|
||||
<Compile Include="Points\HorizontalBezierPointView.cs" />
|
||||
<Compile Include="Components\Converters.cs" />
|
||||
<Compile Include="DefaultAxes.cs" />
|
||||
<Compile Include="Components\TooltipDto.cs" />
|
||||
<Compile Include="CartesianChart.cs" />
|
||||
<Compile Include="LineSeries.cs" />
|
||||
<Compile Include="Extentions.cs" />
|
||||
<Compile Include="Points\PointView.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Separator.cs" />
|
||||
<Compile Include="Series.cs" />
|
||||
<Compile Include="LineSegmentSplitter.cs" />
|
||||
<Compile Include="VisualElement.cs" />
|
||||
<Compile Include="GeoMap.cs" />
|
||||
<Compile Include="WindowAxis.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
<None Include="sign.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="DefaultGeoMapTooltip.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="DefaultLegend.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="DefaultTooltip.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="HeatColorRange.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Colors\metro.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Colors\white.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Colors\black.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Colors\blue.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Colors\material.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\base.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Size\l.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Size\m.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Size\s.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Weight\light.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Weight\bold.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Weight\normal.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core40\Core40.csproj">
|
||||
<Project>{f261c3d7-6194-4625-9516-044081b06028}</Project>
|
||||
<Name>Core40</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp50</s:String></wpf:ResourceDictionary>
|
||||
30
Others/Live-Charts-master/WpfView/WpfView.nuspec
Normal file
30
Others/Live-Charts-master/WpfView/WpfView.nuspec
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0"?>
|
||||
<package >
|
||||
<metadata>
|
||||
<id>LiveCharts.Wpf</id>
|
||||
<version>0.0.0.0</version>
|
||||
<title>LiveCharts.Wpf</title>
|
||||
<authors>Beto Rodriguez</authors>
|
||||
<owners>Beto Rodriguez</owners>
|
||||
<licenseUrl>https://github.com/beto-rodriguez/Live-Charts/blob/master/LICENSE.TXT</licenseUrl>
|
||||
<projectUrl>http://lvcharts.net/</projectUrl>
|
||||
<iconUrl>http://lvcharts.net/Content/Images/Logos/lcred.png</iconUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>Simple, flexible, interactive and powerful data visualization for Wpf</description>
|
||||
<releaseNotes>See https://github.com/beto-rodriguez/Live-Charts/releases</releaseNotes>
|
||||
<copyright>Copyright 2016</copyright>
|
||||
<tags>livechart, live, chart, charting, plot, plots, plotting, graph, graphs, graphing, data, wpf, windows, presentation, foundation, format</tags>
|
||||
<dependencies>
|
||||
<dependency id="LiveCharts" version="0.0.0.0" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="install.ps1" target="tools" />
|
||||
<file src="bin\net403\LiveCharts.Wpf.dll" target="lib\net40" />
|
||||
<file src="bin\net403\LiveCharts.Wpf.pdb" target="lib\net40" />
|
||||
<file src="bin\net403\LiveCharts.Wpf.xml" target="lib\net40" />
|
||||
<file src="bin\net45\LiveCharts.Wpf.dll" target="lib\net45" />
|
||||
<file src="bin\net45\LiveCharts.Wpf.pdb" target="lib\net45" />
|
||||
<file src="bin\net45\LiveCharts.Wpf.xml" target="lib\net45" />
|
||||
</files>
|
||||
</package>
|
||||
3
Others/Live-Charts-master/WpfView/install.ps1
Normal file
3
Others/Live-Charts-master/WpfView/install.ps1
Normal file
@@ -0,0 +1,3 @@
|
||||
param($installPath, $toolsPath, $package, $project)
|
||||
|
||||
$DTE.ItemOperations.Navigate("https://lvcharts.net/thanks/wpf")
|
||||
BIN
Others/Live-Charts-master/WpfView/nuget.exe
Normal file
BIN
Others/Live-Charts-master/WpfView/nuget.exe
Normal file
Binary file not shown.
1140
Others/Live-Charts-master/WpfView/wpf.docs
Normal file
1140
Others/Live-Charts-master/WpfView/wpf.docs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user