mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-16 22:26:36 +08:00
项目结构调整
This commit is contained in:
510
Others/Live-Charts-master/UwpView/AngularGauge.cs
Normal file
510
Others/Live-Charts-master/UwpView/AngularGauge.cs
Normal file
@@ -0,0 +1,510 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Uwp.Components;
|
||||
using LiveCharts.Uwp.Points;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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 {Angle = 180};
|
||||
Stick = new Path
|
||||
{
|
||||
Data = GeometryHelper.Parse("m0,90 a5,5 0 0 0 20,0 l-8,-88 a2,2 0 0 0 -4 0 z"),
|
||||
Fill = new SolidColorBrush(Colors.CornflowerBlue),
|
||||
Stretch = Stretch.Fill,
|
||||
RenderTransformOrigin = new Point(0.5, 0.9),
|
||||
RenderTransform = StickRotateTransform
|
||||
};
|
||||
Canvas.Children.Add(Stick);
|
||||
Canvas.SetZIndex(Stick, 1);
|
||||
|
||||
Canvas.SetBinding(WidthProperty,
|
||||
new Binding { Path = new PropertyPath("ActualWidth"), Source = this });
|
||||
Canvas.SetBinding(HeightProperty,
|
||||
new Binding { Path = new PropertyPath("ActualHeight"), Source = this });
|
||||
|
||||
this.SetIfNotSet(SectionsProperty, new List<AngularSection>());
|
||||
|
||||
Stick.SetBinding(Shape.FillProperty,
|
||||
new Binding {Path = new PropertyPath("NeedleFill"), Source = this});
|
||||
|
||||
Func<double, string> defaultFormatter = x => x.ToString(CultureInfo.InvariantCulture);
|
||||
this.SetIfNotSet(LabelFormatterProperty, defaultFormatter);
|
||||
// this.SetIfNotSet(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; }
|
||||
private Path Stick { get; }
|
||||
private RotateTransform StickRotateTransform { get; }
|
||||
private bool IsControlLaoded { get; set; }
|
||||
private Dictionary<AngularSection, PieSlice> Slices { get; }
|
||||
|
||||
/// <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(2d, 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(10d, 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(TimeSpan.FromMilliseconds(500)));
|
||||
/// <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(new SolidColorBrush(Color.FromArgb(255, 210, 210, 210))));
|
||||
/// <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(new SolidColorBrush(Color.FromArgb(255, 69, 90, 100))));
|
||||
/// <summary>
|
||||
/// Gets o sets the needle fill
|
||||
/// </summary>
|
||||
public Brush NeedleFill
|
||||
{
|
||||
get { return (Brush) GetValue(NeedleFillProperty); }
|
||||
set { SetValue(NeedleFillProperty, value); }
|
||||
}
|
||||
|
||||
//public static readonly DependencyProperty LabelsEffectProperty = DependencyProperty.Register(
|
||||
// "LabelsEffect", typeof (Effect), typeof (AngularGauge), new PropertyMetadata(default(Effect)));
|
||||
|
||||
//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
|
||||
{
|
||||
var sb = new Storyboard();
|
||||
var animation = new DoubleAnimation()
|
||||
{
|
||||
To = alpha,
|
||||
Duration = AnimationsSpeed
|
||||
};
|
||||
|
||||
Storyboard.SetTarget(animation, StickRotateTransform);
|
||||
Storyboard.SetTargetProperty(animation, "Angle");
|
||||
|
||||
sb.Children.Add(animation);
|
||||
sb.Begin();
|
||||
}
|
||||
}
|
||||
|
||||
internal void Draw()
|
||||
{
|
||||
if (!IsControlLaoded) return;
|
||||
|
||||
//No cache for you gauge :( kill and redraw please
|
||||
foreach (var child in Canvas.Children
|
||||
.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;
|
||||
p?.Children.Remove(section);
|
||||
Canvas.Children.Add(section);
|
||||
var ps = (Canvas) slice.Parent;
|
||||
ps?.Children.Remove(slice);
|
||||
Canvas.Children.Add(slice);
|
||||
}
|
||||
|
||||
UpdateSections();
|
||||
|
||||
for (var i = FromValue; i <= ToValue; i += TicksStep)
|
||||
{
|
||||
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("TicksForeground"), Source = this});
|
||||
tick.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding { Path = new PropertyPath("TicksStrokeThickness"), Source = this });
|
||||
}
|
||||
|
||||
for (var i = FromValue; i <= ToValue; i += LabelsStep)
|
||||
{
|
||||
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("LabelsEffect"), 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("TicksForeground"), Source = this });
|
||||
tick.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding { Path = new PropertyPath("TicksStrokeThickness"), 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
98
Others/Live-Charts-master/UwpView/AngularSection.cs
Normal file
98
Others/Live-Charts-master/UwpView/AngularSection.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="Windows.UI.Xaml.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;
|
||||
|
||||
angularSection.Owner?.UpdateSections();
|
||||
}
|
||||
}
|
||||
}
|
||||
66
Others/Live-Charts-master/UwpView/AxesCollection.cs
Normal file
66
Others/Live-Charts-master/UwpView/AxesCollection.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
//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.Uwp.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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)
|
||||
{
|
||||
Chart?.Model?.Updater.Run();
|
||||
|
||||
if (oldItems == null) return;
|
||||
|
||||
foreach (var oldAxis in oldItems)
|
||||
{
|
||||
oldAxis.Clean();
|
||||
var chart = oldAxis.Model?.Chart.View;
|
||||
if (chart == null) continue;
|
||||
chart.RemoveFromView(oldAxis);
|
||||
chart.RemoveFromView(oldAxis.Separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
790
Others/Live-Charts-master/UwpView/Axis.cs
Normal file
790
Others/Live-Charts-master/UwpView/Axis.cs
Normal file
@@ -0,0 +1,790 @@
|
||||
//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.Linq;
|
||||
using System.Windows.Input;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Events;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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();
|
||||
|
||||
this.SetIfNotSet(SeparatorProperty, new Separator());
|
||||
this.SetIfNotSet(SectionsProperty, new SectionsCollection());
|
||||
|
||||
TitleBlock.SetBinding(TextBlock.TextProperty,
|
||||
new Binding {Path = new PropertyPath("Title"), 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; }
|
||||
|
||||
/// <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 Max Value
|
||||
/// </summary>
|
||||
public double PreviousMaxValue { get; internal set; }
|
||||
/// <summary>
|
||||
/// Gets previous Min Value
|
||||
/// </summary>
|
||||
public double PreviousMinValue { 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 (IList<string>) GetValue(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(true, 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 => Model.BotLimit;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actual maximum value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The actual maximum value.
|
||||
/// </value>
|
||||
public double ActualMaxValue => Model.TopLimit;
|
||||
|
||||
/// <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 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 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 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("This 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 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(FontStyle.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(FontStretch.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(new SolidColorBrush(Color.FromArgb(255, 170, 170, 170))));
|
||||
|
||||
/// <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 is enabled property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.Register(
|
||||
"IsEnabled", typeof(bool), typeof(Axis), new PropertyMetadata(default(bool)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is enabled.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is enabled; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool IsEnabled
|
||||
{
|
||||
get { return (bool) GetValue(IsEnabledProperty); }
|
||||
set { SetValue(IsEnabledProperty, 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>
|
||||
/// 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the separator.
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <param name="chart">The chart.</param>
|
||||
public 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);
|
||||
Canvas.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 {Angle = rotationAngle};
|
||||
|
||||
chart.View.AddToView(TitleBlock);
|
||||
}
|
||||
|
||||
TitleBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
|
||||
return string.IsNullOrWhiteSpace(Title)
|
||||
? new CoreSize()
|
||||
: new CoreSize(TitleBlock.DesiredSize.Width, TitleBlock.DesiredSize.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(TitleBlock.DesiredSize.Width, TitleBlock.DesiredSize.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;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal TextBlock BindATextBlock()
|
||||
{
|
||||
var tb = new TextBlock();
|
||||
|
||||
tb.SetBinding(TextBlock.FontFamilyProperty,
|
||||
new Binding { Path = new PropertyPath("FontFamily"), Source = this });
|
||||
tb.SetBinding(TextBlock.FontSizeProperty,
|
||||
new Binding { Path = new PropertyPath("FontSize"), Source = this });
|
||||
tb.SetBinding(TextBlock.FontStretchProperty,
|
||||
new Binding { Path = new PropertyPath("FontStretch"), Source = this });
|
||||
tb.SetBinding(TextBlock.FontStyleProperty,
|
||||
new Binding { Path = new PropertyPath("FontStyle"), Source = this });
|
||||
tb.SetBinding(TextBlock.FontWeightProperty,
|
||||
new Binding { Path = new PropertyPath("FontWeight"), Source = this });
|
||||
tb.SetBinding(TextBlock.ForegroundProperty,
|
||||
new Binding { Path = new PropertyPath("Foreground"), 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("Stroke"), Source = s});
|
||||
try
|
||||
{
|
||||
l.SetBinding(Shape.StrokeDashArrayProperty,
|
||||
new Binding { Path = new PropertyPath("StrokeDashArray"), Source = s });
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// temporarily ignore it
|
||||
}
|
||||
|
||||
l.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding {Path = new PropertyPath("StrokeThickness"), Source = s});
|
||||
l.SetBinding(VisibilityProperty,
|
||||
new Binding {Path = new PropertyPath("Visibility"), 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;
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
PreviewRangeChanged?.Invoke(e);
|
||||
if (PreviewRangeChangedCommand != null && PreviewRangeChangedCommand.CanExecute(e))
|
||||
PreviewRangeChangedCommand.Execute(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
471
Others/Live-Charts-master/UwpView/AxisSection.cs
Normal file
471
Others/Live-Charts-master/UwpView/AxisSection.cs
Normal file
@@ -0,0 +1,471 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Helpers;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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 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;
|
||||
Canvas.SetZIndex(_rectangle, Canvas.GetZIndex(this));
|
||||
BindingOperations.SetBinding(_rectangle, VisibilityProperty,
|
||||
new Binding {Path = new PropertyPath(nameof(Visibility)), 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 : FromValue, source, Model.Chart, axis) + uw;
|
||||
#pragma warning restore 618
|
||||
#pragma warning disable 618
|
||||
var to = ChartFunctions.ToDrawMargin(double.IsNaN(ToValue) ? Value + 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.BeginDoubleAnimation(nameof(Width), w > 0 ? w : 0, anSpeed);
|
||||
_rectangle.BeginDoubleAnimation("Canvas.Left", 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.BeginDoubleAnimation("Canvas.Left", from, anSpeed);
|
||||
_rectangle.BeginDoubleAnimation(nameof(Height), 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;
|
||||
|
||||
_label.UpdateLayout();
|
||||
|
||||
var transform = new LabelEvaluation(axis.View.LabelsRotation,
|
||||
_label.Width + 10, _label.Height, axis, source);
|
||||
|
||||
_label.RenderTransform = Math.Abs(transform.LabelAngle) > 1
|
||||
? new RotateTransform {Angle = transform.LabelAngle}
|
||||
: null;
|
||||
|
||||
var toLine = ChartFunctions.ToPlotArea(Value, 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)
|
||||
{
|
||||
if (Model.View.DisableAnimations || DisableAnimations)
|
||||
{
|
||||
Canvas.SetLeft(_label, labelTab);
|
||||
Canvas.SetTop(_label, toLabel);
|
||||
return;
|
||||
}
|
||||
|
||||
_label.BeginDoubleAnimation("Canvas.Top", toLabel, chart.View.AnimationsSpeed);
|
||||
_label.BeginDoubleAnimation("Canvas.Left", labelTab, chart.View.AnimationsSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Model.View.DisableAnimations || DisableAnimations)
|
||||
{
|
||||
Canvas.SetLeft(_label, toLabel);
|
||||
Canvas.SetTop(_label, labelTab);
|
||||
return;
|
||||
}
|
||||
|
||||
_label.BeginDoubleAnimation("Canvas.Left", toLabel, chart.View.AnimationsSpeed);
|
||||
_label.BeginDoubleAnimation("Canvas.Top", labelTab, chart.View.AnimationsSpeed);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
233
Others/Live-Charts-master/UwpView/CandleSeries.cs
Normal file
233
Others/Live-Charts-master/UwpView/CandleSeries.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
//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 Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Components;
|
||||
using LiveCharts.Uwp.Points;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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(35d));
|
||||
/// <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(new SolidColorBrush(Color.FromArgb(255, 254, 178, 0))));
|
||||
/// <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(new SolidColorBrush(Color.FromArgb(255, 238, 83, 80))));
|
||||
/// <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 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 = (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 = Canvas.GetZIndex(this);
|
||||
|
||||
pbv.HighToLowLine.StrokeThickness = StrokeThickness;
|
||||
pbv.HighToLowLine.StrokeDashArray = StrokeDashArray;
|
||||
pbv.HighToLowLine.Visibility = Visibility;
|
||||
Canvas.SetZIndex(pbv.HighToLowLine, i);
|
||||
|
||||
pbv.OpenToCloseRectangle.Fill = Fill;
|
||||
pbv.OpenToCloseRectangle.StrokeThickness = StrokeThickness;
|
||||
pbv.OpenToCloseRectangle.Stroke = Stroke;
|
||||
pbv.OpenToCloseRectangle.StrokeDashArray = StrokeDashArray;
|
||||
pbv.OpenToCloseRectangle.Visibility = Visibility;
|
||||
Canvas.SetZIndex(pbv.HighToLowLine, i);
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = new SolidColorBrush(Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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.OpenToCloseRectangle.Fill = IncreaseBrush;
|
||||
pbv.OpenToCloseRectangle.Stroke = IncreaseBrush;
|
||||
}
|
||||
else
|
||||
{
|
||||
pbv.HighToLowLine.Stroke = DecreaseBrush;
|
||||
pbv.OpenToCloseRectangle.Fill = DecreaseBrush;
|
||||
pbv.OpenToCloseRectangle.Stroke = DecreaseBrush;
|
||||
}
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
Func<ChartPoint, string> defaultLabel = x =>
|
||||
string.Format("O: {0}, H: {1}, L: {2} C: {3}", x.Open, x.High, x.Low, x.Close);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
78
Others/Live-Charts-master/UwpView/CartesianChart.cs
Normal file
78
Others/Live-Charts-master/UwpView/CartesianChart.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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);
|
||||
|
||||
SetValue(SeriesProperty,
|
||||
Windows.ApplicationModel.DesignMode.DesignModeEnabled
|
||||
? GetDesignerModeCollection()
|
||||
: new SeriesCollection());
|
||||
|
||||
this.SetIfNotSet(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
1521
Others/Live-Charts-master/UwpView/Charts/Base/Chart.cs
Normal file
1521
Others/Live-Charts-master/UwpView/Charts/Base/Chart.cs
Normal file
File diff suppressed because it is too large
Load Diff
34
Others/Live-Charts-master/UwpView/ColorsCollection.cs
Normal file
34
Others/Live-Charts-master/UwpView/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 Windows.UI;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ColorsCollection : List<Color>
|
||||
{
|
||||
}
|
||||
}
|
||||
224
Others/Live-Charts-master/UwpView/ColumnSeries.cs
Normal file
224
Others/Live-Charts-master/UwpView/ColumnSeries.cs
Normal file
@@ -0,0 +1,224 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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(BarLabelPosition.Top, 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;
|
||||
var zIndex = Canvas.GetZIndex(this);
|
||||
Canvas.SetZIndex(pbv.Rectangle, zIndex);
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = new SolidColorBrush(Windows.UI.Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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()
|
||||
{
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 0d);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
164
Others/Live-Charts-master/UwpView/Components/AnimationsHelper.cs
Normal file
164
Others/Live-Charts-master/UwpView/Components/AnimationsHelper.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 Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
|
||||
namespace LiveCharts.Uwp.Components
|
||||
{
|
||||
internal static class AnimationsHelper
|
||||
{
|
||||
public static DoubleAnimation CreateDouble(double? to, Duration duration, string targetProperty)
|
||||
{
|
||||
var animation = new DoubleAnimation
|
||||
{
|
||||
To = to,
|
||||
Duration = duration,
|
||||
EnableDependentAnimation = true
|
||||
};
|
||||
Storyboard.SetTargetProperty(animation, targetProperty);
|
||||
return animation;
|
||||
}
|
||||
|
||||
public static PointAnimation CreatePoint(Point to, Duration duration, string targetProperty)
|
||||
{
|
||||
var animation = new PointAnimation
|
||||
{
|
||||
To = to,
|
||||
Duration = duration,
|
||||
EnableDependentAnimation = true
|
||||
};
|
||||
Storyboard.SetTargetProperty(animation, targetProperty);
|
||||
return animation;
|
||||
}
|
||||
|
||||
public static PointAnimation CreatePoint(Point from, Point to, Duration duration, string targetProperty)
|
||||
{
|
||||
var animation = new PointAnimation
|
||||
{
|
||||
From = from,
|
||||
To = to,
|
||||
Duration = duration
|
||||
};
|
||||
Storyboard.SetTargetProperty(animation, targetProperty);
|
||||
return animation;
|
||||
}
|
||||
|
||||
public static ColorAnimation CreateColor(Color to, Duration duration, string targetProperty)
|
||||
{
|
||||
var animation = new ColorAnimation
|
||||
{
|
||||
To = to,
|
||||
Duration = duration,
|
||||
EnableDependentAnimation = true
|
||||
};
|
||||
Storyboard.SetTargetProperty(animation, targetProperty);
|
||||
return animation;
|
||||
}
|
||||
|
||||
public static void BeginDoubleAnimation(this DependencyObject target, string path, double? to,
|
||||
Duration duration)
|
||||
{
|
||||
var animation = new DoubleAnimation
|
||||
{
|
||||
To = to,
|
||||
Duration = duration,
|
||||
EnableDependentAnimation = true
|
||||
};
|
||||
target.BeginAnimation(animation, path);
|
||||
}
|
||||
|
||||
public static void BeginDoubleAnimation(this DependencyObject target, string path, double? from, double? to,
|
||||
Duration duration)
|
||||
{
|
||||
var animation = new DoubleAnimation
|
||||
{
|
||||
From = from,
|
||||
To = to,
|
||||
Duration = duration,
|
||||
EnableDependentAnimation = true
|
||||
};
|
||||
target.BeginAnimation(animation, path);
|
||||
}
|
||||
|
||||
public static void BeginPointAnimation(this DependencyObject target, string path, Point to, Duration duration)
|
||||
{
|
||||
var animation = CreatePoint(to, duration, path);
|
||||
target.BeginAnimation(animation, path);
|
||||
}
|
||||
|
||||
public static void BeginColorAnimation(this DependencyObject target, string path, Color to, Duration duration)
|
||||
{
|
||||
var animation = CreateColor(to, duration, path);
|
||||
target.BeginAnimation(animation, path);
|
||||
}
|
||||
|
||||
public static void BeginAnimation(this DependencyObject target, Timeline animation, string path)
|
||||
{
|
||||
var sb = new Storyboard();
|
||||
Storyboard.SetTarget(animation, target);
|
||||
Storyboard.SetTargetProperty(animation, path);
|
||||
sb.Children.Add(animation);
|
||||
sb.Begin();
|
||||
}
|
||||
|
||||
public static void CreateStoryBoardAndBegin(DependencyObject target, params Timeline[] animation)
|
||||
{
|
||||
var sb = new Storyboard();
|
||||
foreach (var timeline in animation)
|
||||
{
|
||||
Storyboard.SetTarget(timeline, target);
|
||||
sb.Children.Add(timeline);
|
||||
}
|
||||
sb.Begin();
|
||||
}
|
||||
|
||||
public static void CreateCanvasStoryBoardAndBegin(this DependencyObject target, double? toX, double? toY, Duration duration)
|
||||
{
|
||||
var xAnimation = CreateDouble(toX, duration, "(Canvas.Left)");
|
||||
var yAnimation = CreateDouble(toY, duration, "(Canvas.Top)");
|
||||
CreateStoryBoardAndBegin(target, xAnimation, yAnimation);
|
||||
}
|
||||
|
||||
public static void CreateY1Y2StoryBoardAndBegin(this DependencyObject target, double? toY1, double? toY2,
|
||||
Duration duration)
|
||||
{
|
||||
var y1Animation = CreateDouble(toY1, duration, nameof(Line.Y1));
|
||||
var y2Animation = CreateDouble(toY2, duration, nameof(Line.Y2));
|
||||
CreateStoryBoardAndBegin(target, y1Animation, y2Animation);
|
||||
}
|
||||
|
||||
public static Storyboard CreateStoryBoard(DependencyObject target,params Timeline[] animation)
|
||||
{
|
||||
var sb = new Storyboard();
|
||||
foreach (var timeline in animation)
|
||||
{
|
||||
Storyboard.SetTarget(timeline, target);
|
||||
sb.Children.Add(timeline);
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Uwp.Components
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="LiveCharts.Definitions.Charts.ISeparatorElementView" />
|
||||
public class AxisSeparatorElement : ISeparatorElementView
|
||||
{
|
||||
/// <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; }
|
||||
|
||||
/// <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;
|
||||
TextBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
|
||||
var transform = new LabelEvaluation(axis.View.LabelsRotation,
|
||||
TextBlock.DesiredSize.Width, TextBlock.DesiredSize.Height, axis, source);
|
||||
|
||||
TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
|
||||
? new RotateTransform { Angle = 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)
|
||||
{
|
||||
var x1 = AnimationsHelper.CreateDouble(chart.DrawMargin.Left, chart.View.AnimationsSpeed, nameof(Line.X1));
|
||||
var x2 = AnimationsHelper.CreateDouble(chart.DrawMargin.Left + chart.DrawMargin.Width, chart.View.AnimationsSpeed, nameof(Line.X2));
|
||||
var y1 = AnimationsHelper.CreateDouble(toLine, chart.View.AnimationsSpeed, nameof(Line.Y1));
|
||||
var y2 = AnimationsHelper.CreateDouble(toLine, chart.View.AnimationsSpeed, nameof(Line.Y2));
|
||||
|
||||
AnimationsHelper.CreateStoryBoardAndBegin(Line, x1, x2, y1, y2);
|
||||
|
||||
var tb1 = AnimationsHelper.CreateDouble(toLabel, chart.View.AnimationsSpeed, "(Canvas.Top)");
|
||||
var tb2 = AnimationsHelper.CreateDouble(tab, chart.View.AnimationsSpeed, "(Canvas.Left)");
|
||||
|
||||
AnimationsHelper.CreateStoryBoardAndBegin(TextBlock, tb1, tb2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var x1 = AnimationsHelper.CreateDouble(toLine, chart.View.AnimationsSpeed, nameof(Line.X1));
|
||||
var x2 = AnimationsHelper.CreateDouble(toLine, chart.View.AnimationsSpeed, nameof(Line.X2));
|
||||
var y1 = AnimationsHelper.CreateDouble(chart.DrawMargin.Top, chart.View.AnimationsSpeed, nameof(Line.Y1));
|
||||
var y2 = AnimationsHelper.CreateDouble(chart.DrawMargin.Top + chart.DrawMargin.Height, chart.View.AnimationsSpeed, nameof(Line.Y2));
|
||||
|
||||
AnimationsHelper.CreateStoryBoardAndBegin(Line, x1, x2, y1, y2);
|
||||
|
||||
var tb1 = AnimationsHelper.CreateDouble(toLabel, chart.View.AnimationsSpeed, "(Canvas.Left)");
|
||||
var tb2 = AnimationsHelper.CreateDouble(tab, chart.View.AnimationsSpeed, "(Canvas.Top)");
|
||||
|
||||
AnimationsHelper.CreateStoryBoardAndBegin(TextBlock, tb1, tb2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <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.BeginDoubleAnimation("Opacity", 0, 1, chart.View.AnimationsSpeed);
|
||||
|
||||
if (Line.Visibility != Visibility.Collapsed)
|
||||
Line.BeginDoubleAnimation("Opacity", 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) =>
|
||||
{
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
chart.View.RemoveFromView(TextBlock);
|
||||
chart.View.RemoveFromView(Line);
|
||||
});
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
};
|
||||
|
||||
TextBlock.BeginAnimation(anim, "Opacity");
|
||||
|
||||
Line.BeginDoubleAnimation("Opacity", 1, 0, chart.View.AnimationsSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
78
Others/Live-Charts-master/UwpView/Components/BrushCloner.cs
Normal file
78
Others/Live-Charts-master/UwpView/Components/BrushCloner.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
//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 Windows.UI.Xaml.Media;
|
||||
|
||||
namespace LiveCharts.Uwp.Components
|
||||
{
|
||||
internal static class BrushCloner
|
||||
{
|
||||
public static Brush Clone(this Brush brush)
|
||||
{
|
||||
var colorBrush = brush as SolidColorBrush;
|
||||
if (colorBrush != null)
|
||||
{
|
||||
return new SolidColorBrush
|
||||
{
|
||||
Color = colorBrush.Color,
|
||||
Opacity = colorBrush.Opacity,
|
||||
Transform = colorBrush.Transform,
|
||||
RelativeTransform = colorBrush.RelativeTransform
|
||||
};
|
||||
}
|
||||
|
||||
var gradientBrush = brush as LinearGradientBrush;
|
||||
if (gradientBrush != null)
|
||||
{
|
||||
return new LinearGradientBrush
|
||||
{
|
||||
ColorInterpolationMode = gradientBrush.ColorInterpolationMode,
|
||||
EndPoint = gradientBrush.EndPoint,
|
||||
GradientStops = gradientBrush.GradientStops,
|
||||
MappingMode = gradientBrush.MappingMode,
|
||||
Opacity = gradientBrush.Opacity,
|
||||
RelativeTransform = gradientBrush.RelativeTransform,
|
||||
StartPoint = gradientBrush.StartPoint,
|
||||
SpreadMethod = gradientBrush.SpreadMethod,
|
||||
Transform = gradientBrush.Transform
|
||||
};
|
||||
}
|
||||
|
||||
var imageBrush = brush as ImageBrush;
|
||||
if (imageBrush != null)
|
||||
{
|
||||
return new ImageBrush
|
||||
{
|
||||
AlignmentX = imageBrush.AlignmentX,
|
||||
AlignmentY = imageBrush.AlignmentY,
|
||||
ImageSource = imageBrush.ImageSource,
|
||||
Opacity = imageBrush.Opacity,
|
||||
RelativeTransform = imageBrush.RelativeTransform,
|
||||
Stretch = imageBrush.Stretch,
|
||||
Transform = imageBrush.Transform
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
94
Others/Live-Charts-master/UwpView/Components/ChartUpdater.cs
Normal file
94
Others/Live-Charts-master/UwpView/Components/ChartUpdater.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Uwp.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, object args)
|
||||
{
|
||||
UpdaterTick(RequiresRestart, false);
|
||||
}
|
||||
|
||||
private void UpdaterTick(bool restartView, bool force)
|
||||
{
|
||||
var uwpfChart = (Chart) Chart.View;
|
||||
if (uwpfChart.Visibility != Visibility.Visible && !uwpfChart.IsMocked) return;
|
||||
|
||||
Chart.ControlSize = uwpfChart.IsMocked
|
||||
? uwpfChart.Model.ControlSize
|
||||
: new CoreSize(uwpfChart.ActualWidth, uwpfChart.ActualHeight);
|
||||
Timer.Stop();
|
||||
Update(restartView, force);
|
||||
IsUpdating = false;
|
||||
|
||||
RequiresRestart = false;
|
||||
|
||||
uwpfChart.ChartUpdated();
|
||||
uwpfChart.PrepareScrolBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
66
Others/Live-Charts-master/UwpView/Components/Converters.cs
Normal file
66
Others/Live-Charts-master/UwpView/Components/Converters.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
//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.Linq;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace LiveCharts.Uwp.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, string language)
|
||||
{
|
||||
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 == DefaultGeometries.None
|
||||
? new PointGeometry("M 0, 0.5 h 1, 0.5 Z").Parse()
|
||||
: serie.PointGeometry.Parse()
|
||||
};
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.IO;
|
||||
using System.Xml;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Markup;
|
||||
|
||||
namespace LiveCharts.Uwp.Components
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class DefaultXamlReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the specified type.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DataTemplate DataLabelTemplate()
|
||||
{
|
||||
const string markup =
|
||||
@"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
|
||||
<TextBlock Text=""{Binding FormattedText}""></TextBlock>
|
||||
</DataTemplate>";
|
||||
return XamlReader.Load(markup) as DataTemplate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace LiveCharts.Uwp.Components
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class DependencyObjectExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets if not set.
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="dp">The dp.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public static void SetIfNotSet(this DependencyObject o, DependencyProperty dp, object value)
|
||||
{
|
||||
if (o.ReadLocalValue(dp) == DependencyProperty.UnsetValue)
|
||||
o.SetValue(dp, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace LiveCharts.Uwp.Components
|
||||
{
|
||||
internal static class GeometryHelper
|
||||
{
|
||||
public static Geometry Parse(string data)
|
||||
{
|
||||
var parser = new GeometryParser();
|
||||
return parser.Convert(data);
|
||||
}
|
||||
|
||||
public static Geometry Parse(this PointGeometry geometry)
|
||||
{
|
||||
return geometry == null ? null : Parse(geometry.Data);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Attribute" />
|
||||
public class GeometryData : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GeometryData"/> class.
|
||||
/// </summary>
|
||||
/// <param name="data">The data.</param>
|
||||
public GeometryData(string data)
|
||||
{
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the data.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The data.
|
||||
/// </value>
|
||||
public string Data { get; set; }
|
||||
}
|
||||
}
|
||||
679
Others/Live-Charts-master/UwpView/Components/GeometryParser.cs
Normal file
679
Others/Live-Charts-master/UwpView/Components/GeometryParser.cs
Normal file
@@ -0,0 +1,679 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace LiveCharts.Uwp.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// A String-To-PathGeometry Parser from https://stringtopathgeometry.codeplex.com/
|
||||
/// </summary>
|
||||
internal class GeometryParser
|
||||
{
|
||||
#region Const & Private Variables
|
||||
const bool AllowSign = true;
|
||||
const bool AllowComma = true;
|
||||
const bool IsFilled = true;
|
||||
const bool IsClosed = true;
|
||||
|
||||
IFormatProvider _formatProvider;
|
||||
|
||||
PathFigure _figure; // Figure object, which will accept parsed segments
|
||||
string _pathString; // Input string to be parsed
|
||||
int _pathLength;
|
||||
int _curIndex; // Location to read next character from
|
||||
bool _figureStarted; // StartFigure is effective
|
||||
|
||||
Point _lastStart; // Last figure starting point
|
||||
Point _lastPoint; // Last point
|
||||
Point _secondLastPoint; // The point before last point
|
||||
|
||||
char _token; // Non whitespace character returned by ReadToken
|
||||
#endregion
|
||||
|
||||
#region Public Functionality
|
||||
/// <summary>
|
||||
/// Main conversion routine - converts string path data definition to PathGeometry object
|
||||
/// </summary>
|
||||
/// <param name="path">String with path data definition</param>
|
||||
/// <returns>PathGeometry object created from string definition</returns>
|
||||
public PathGeometry Convert(string path)
|
||||
{
|
||||
if (path == null)
|
||||
throw new ArgumentException("Path string cannot be null!", nameof(path));
|
||||
|
||||
if (path.Length == 0)
|
||||
throw new ArgumentException("Path string cannot be empty!", nameof(path));
|
||||
|
||||
return Parse(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Main back conversion routine - converts PathGeometry object to its string equivalent
|
||||
/// </summary>
|
||||
/// <param name="geometry">Path Geometry object</param>
|
||||
/// <returns>String equivalent to PathGeometry contents</returns>
|
||||
public string ConvertBack(PathGeometry geometry)
|
||||
{
|
||||
if (geometry == null)
|
||||
throw new ArgumentException("Path Geometry cannot be null!", nameof(geometry));
|
||||
|
||||
return ParseBack(geometry);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Functionality
|
||||
/// <summary>
|
||||
/// Main parser routine, which loops over each char in received string, and performs actions according to command/parameter being passed
|
||||
/// </summary>
|
||||
/// <param name="path">String with path data definition</param>
|
||||
/// <returns>PathGeometry object created from string definition</returns>
|
||||
private PathGeometry Parse(string path)
|
||||
{
|
||||
PathGeometry pathGeometry = null;
|
||||
|
||||
_formatProvider = CultureInfo.InvariantCulture;
|
||||
_pathString = path;
|
||||
_pathLength = path.Length;
|
||||
_curIndex = 0;
|
||||
|
||||
_secondLastPoint = new Point(0, 0);
|
||||
_lastPoint = new Point(0, 0);
|
||||
_lastStart = new Point(0, 0);
|
||||
|
||||
_figureStarted = false;
|
||||
|
||||
var first = true;
|
||||
|
||||
var lastCmd = ' ';
|
||||
|
||||
while (ReadToken()) // Empty path is allowed in XAML
|
||||
{
|
||||
char cmd = _token;
|
||||
|
||||
if (first)
|
||||
{
|
||||
if ((cmd != 'M') && (cmd != 'm') && (cmd != 'f') && (cmd != 'F')) // Path starts with M|m
|
||||
{
|
||||
ThrowBadToken();
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case 'f':
|
||||
case 'F':
|
||||
pathGeometry = new PathGeometry();
|
||||
var num = ReadNumber(!AllowComma);
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
||||
pathGeometry.FillRule = num == 0 ? FillRule.EvenOdd : FillRule.Nonzero;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
case 'M':
|
||||
// XAML allows multiple points after M/m
|
||||
_lastPoint = ReadPoint(cmd, !AllowComma);
|
||||
|
||||
_figure = new PathFigure
|
||||
{
|
||||
StartPoint = _lastPoint,
|
||||
IsFilled = IsFilled,
|
||||
IsClosed = !IsClosed
|
||||
};
|
||||
//context.BeginFigure(_lastPoint, IsFilled, !IsClosed);
|
||||
_figureStarted = true;
|
||||
_lastStart = _lastPoint;
|
||||
lastCmd = 'M';
|
||||
|
||||
while (IsNumber(AllowComma))
|
||||
{
|
||||
_lastPoint = ReadPoint(cmd, !AllowComma);
|
||||
|
||||
var lineSegment = new LineSegment {Point = _lastPoint};
|
||||
_figure.Segments.Add(lineSegment);
|
||||
//context.LineTo(_lastPoint, IsStroked, !IsSmoothJoin);
|
||||
lastCmd = 'L';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
case 'L':
|
||||
case 'h':
|
||||
case 'H':
|
||||
case 'v':
|
||||
case 'V':
|
||||
EnsureFigure();
|
||||
|
||||
do
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case 'l': _lastPoint = ReadPoint(cmd, !AllowComma); break;
|
||||
case 'L': _lastPoint = ReadPoint(cmd, !AllowComma); break;
|
||||
case 'h': _lastPoint.X += ReadNumber(!AllowComma); break;
|
||||
case 'H': _lastPoint.X = ReadNumber(!AllowComma); break;
|
||||
case 'v': _lastPoint.Y += ReadNumber(!AllowComma); break;
|
||||
case 'V': _lastPoint.Y = ReadNumber(!AllowComma); break;
|
||||
}
|
||||
|
||||
var lineSegment = new LineSegment {Point = _lastPoint};
|
||||
_figure.Segments.Add(lineSegment);
|
||||
//context.LineTo(_lastPoint, IsStroked, !IsSmoothJoin);
|
||||
}
|
||||
while (IsNumber(AllowComma));
|
||||
|
||||
lastCmd = 'L';
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
case 'C': // cubic Bezier
|
||||
case 's':
|
||||
case 'S': // smooth cublic Bezier
|
||||
EnsureFigure();
|
||||
|
||||
do
|
||||
{
|
||||
Point p;
|
||||
|
||||
if ((cmd == 's') || (cmd == 'S'))
|
||||
{
|
||||
p = lastCmd == 'C' ? Reflect() : _lastPoint;
|
||||
|
||||
_secondLastPoint = ReadPoint(cmd, !AllowComma);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = ReadPoint(cmd, !AllowComma);
|
||||
|
||||
_secondLastPoint = ReadPoint(cmd, AllowComma);
|
||||
}
|
||||
|
||||
_lastPoint = ReadPoint(cmd, AllowComma);
|
||||
|
||||
var bizierSegment = new BezierSegment
|
||||
{
|
||||
Point1 = p,
|
||||
Point2 = _secondLastPoint,
|
||||
Point3 = _lastPoint
|
||||
};
|
||||
_figure.Segments.Add(bizierSegment);
|
||||
//context.BezierTo(p, _secondLastPoint, _lastPoint, IsStroked, !IsSmoothJoin);
|
||||
|
||||
lastCmd = 'C';
|
||||
}
|
||||
while (IsNumber(AllowComma));
|
||||
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
case 'Q': // quadratic Bezier
|
||||
case 't':
|
||||
case 'T': // smooth quadratic Bezier
|
||||
EnsureFigure();
|
||||
|
||||
do
|
||||
{
|
||||
if ((cmd == 't') || (cmd == 'T'))
|
||||
{
|
||||
_secondLastPoint = lastCmd == 'Q' ? Reflect() : _lastPoint;
|
||||
|
||||
_lastPoint = ReadPoint(cmd, !AllowComma);
|
||||
}
|
||||
else
|
||||
{
|
||||
_secondLastPoint = ReadPoint(cmd, !AllowComma);
|
||||
_lastPoint = ReadPoint(cmd, AllowComma);
|
||||
}
|
||||
|
||||
var quadraticBezierSegment = new QuadraticBezierSegment
|
||||
{
|
||||
Point1 = _secondLastPoint,
|
||||
Point2 = _lastPoint
|
||||
};
|
||||
_figure.Segments.Add(quadraticBezierSegment);
|
||||
//context.QuadraticBezierTo(_secondLastPoint, _lastPoint, IsStroked, !IsSmoothJoin);
|
||||
|
||||
lastCmd = 'Q';
|
||||
}
|
||||
while (IsNumber(AllowComma));
|
||||
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
case 'A':
|
||||
EnsureFigure();
|
||||
|
||||
do
|
||||
{
|
||||
// A 3,4 5, 0, 0, 6,7
|
||||
var w = ReadNumber(!AllowComma);
|
||||
var h = ReadNumber(AllowComma);
|
||||
var rotation = ReadNumber(AllowComma);
|
||||
var large = ReadBool();
|
||||
var sweep = ReadBool();
|
||||
|
||||
_lastPoint = ReadPoint(cmd, AllowComma);
|
||||
|
||||
var arcSegment = new ArcSegment
|
||||
{
|
||||
Point = _lastPoint,
|
||||
Size = new Size(w, h),
|
||||
RotationAngle = rotation,
|
||||
IsLargeArc = large,
|
||||
SweepDirection = sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise
|
||||
};
|
||||
_figure.Segments.Add(arcSegment);
|
||||
//context.ArcTo(
|
||||
// _lastPoint,
|
||||
// new Size(w, h),
|
||||
// rotation,
|
||||
// large,
|
||||
// sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise,
|
||||
// IsStroked,
|
||||
// !IsSmoothJoin
|
||||
// );
|
||||
}
|
||||
while (IsNumber(AllowComma));
|
||||
|
||||
lastCmd = 'A';
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
case 'Z':
|
||||
EnsureFigure();
|
||||
_figure.IsClosed = IsClosed;
|
||||
//context.SetClosedState(IsClosed);
|
||||
|
||||
_figureStarted = false;
|
||||
lastCmd = 'Z';
|
||||
|
||||
_lastPoint = _lastStart; // Set reference point to be first point of current figure
|
||||
break;
|
||||
|
||||
default:
|
||||
ThrowBadToken();
|
||||
break;
|
||||
}
|
||||
|
||||
if (null != _figure)
|
||||
{
|
||||
if (_figure.IsClosed)
|
||||
{
|
||||
if (null == pathGeometry)
|
||||
pathGeometry = new PathGeometry();
|
||||
|
||||
pathGeometry.Figures.Add(_figure);
|
||||
|
||||
_figure = null;
|
||||
first = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (null != _figure)
|
||||
{
|
||||
if (null == pathGeometry)
|
||||
pathGeometry = new PathGeometry();
|
||||
|
||||
if (!pathGeometry.Figures.Contains(_figure))
|
||||
pathGeometry.Figures.Add(_figure);
|
||||
|
||||
}
|
||||
return pathGeometry;
|
||||
}
|
||||
|
||||
void SkipDigits(bool signAllowed)
|
||||
{
|
||||
// Allow for a sign
|
||||
if (signAllowed && More() && ((_pathString[_curIndex] == '-') || _pathString[_curIndex] == '+'))
|
||||
{
|
||||
_curIndex++;
|
||||
}
|
||||
|
||||
while (More() && (_pathString[_curIndex] >= '0') && (_pathString[_curIndex] <= '9'))
|
||||
{
|
||||
_curIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
bool ReadBool()
|
||||
{
|
||||
SkipWhiteSpace(AllowComma);
|
||||
|
||||
if (More())
|
||||
{
|
||||
_token = _pathString[_curIndex++];
|
||||
|
||||
if (_token == '0')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (_token == '1')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ThrowBadToken();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Point Reflect()
|
||||
{
|
||||
return new Point(2 * _lastPoint.X - _secondLastPoint.X,
|
||||
2 * _lastPoint.Y - _secondLastPoint.Y);
|
||||
}
|
||||
|
||||
private void EnsureFigure()
|
||||
{
|
||||
if (!_figureStarted)
|
||||
{
|
||||
_figure = new PathFigure {StartPoint = _lastStart};
|
||||
|
||||
//_context.BeginFigure(_lastStart, IsFilled, !IsClosed);
|
||||
_figureStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
double ReadNumber(bool allowComma)
|
||||
{
|
||||
if (!IsNumber(allowComma))
|
||||
{
|
||||
ThrowBadToken();
|
||||
}
|
||||
|
||||
bool simple = true;
|
||||
int start = _curIndex;
|
||||
|
||||
//
|
||||
// Allow for a sign
|
||||
//
|
||||
// There are numbers that cannot be preceded with a sign, for instance, -NaN, but it's
|
||||
// fine to ignore that at this point, since the CLR parser will catch this later.
|
||||
//
|
||||
if (More() && ((_pathString[_curIndex] == '-') || _pathString[_curIndex] == '+'))
|
||||
{
|
||||
_curIndex++;
|
||||
}
|
||||
|
||||
// Check for Infinity (or -Infinity).
|
||||
if (More() && (_pathString[_curIndex] == 'I'))
|
||||
{
|
||||
//
|
||||
// Don't bother reading the characters, as the CLR parser will
|
||||
// do this for us later.
|
||||
//
|
||||
_curIndex = Math.Min(_curIndex + 8, _pathLength); // "Infinity" has 8 characters
|
||||
simple = false;
|
||||
}
|
||||
// Check for NaN
|
||||
else if (More() && (_pathString[_curIndex] == 'N'))
|
||||
{
|
||||
//
|
||||
// Don't bother reading the characters, as the CLR parser will
|
||||
// do this for us later.
|
||||
//
|
||||
_curIndex = Math.Min(_curIndex + 3, _pathLength); // "NaN" has 3 characters
|
||||
simple = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SkipDigits(!AllowSign);
|
||||
|
||||
// Optional period, followed by more digits
|
||||
if (More() && (_pathString[_curIndex] == '.'))
|
||||
{
|
||||
simple = false;
|
||||
_curIndex++;
|
||||
SkipDigits(!AllowSign);
|
||||
}
|
||||
|
||||
// Exponent
|
||||
if (More() && ((_pathString[_curIndex] == 'E') || (_pathString[_curIndex] == 'e')))
|
||||
{
|
||||
simple = false;
|
||||
_curIndex++;
|
||||
SkipDigits(AllowSign);
|
||||
}
|
||||
}
|
||||
|
||||
if (simple && (_curIndex <= (start + 8))) // 32-bit integer
|
||||
{
|
||||
int sign = 1;
|
||||
|
||||
if (_pathString[start] == '+')
|
||||
{
|
||||
start++;
|
||||
}
|
||||
else if (_pathString[start] == '-')
|
||||
{
|
||||
start++;
|
||||
sign = -1;
|
||||
}
|
||||
|
||||
int value = 0;
|
||||
|
||||
while (start < _curIndex)
|
||||
{
|
||||
value = value * 10 + (_pathString[start] - '0');
|
||||
start++;
|
||||
}
|
||||
|
||||
return value * sign;
|
||||
}
|
||||
else
|
||||
{
|
||||
string subString = _pathString.Substring(start, _curIndex - start);
|
||||
|
||||
try
|
||||
{
|
||||
return System.Convert.ToDouble(subString, _formatProvider);
|
||||
}
|
||||
catch (FormatException except)
|
||||
{
|
||||
throw new FormatException(string.Format("Unexpected character in path '{0}' at position {1}", _pathString, _curIndex - 1), except);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsNumber(bool allowComma)
|
||||
{
|
||||
bool commaMet = SkipWhiteSpace(allowComma);
|
||||
|
||||
if (More())
|
||||
{
|
||||
_token = _pathString[_curIndex];
|
||||
|
||||
// Valid start of a number
|
||||
if ((_token == '.') || (_token == '-') || (_token == '+') || ((_token >= '0') && (_token <= '9'))
|
||||
|| (_token == 'I') // Infinity
|
||||
|| (_token == 'N')) // NaN
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (commaMet) // Only allowed between numbers
|
||||
{
|
||||
ThrowBadToken();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Point ReadPoint(char cmd, bool allowcomma)
|
||||
{
|
||||
double x = ReadNumber(allowcomma);
|
||||
double y = ReadNumber(AllowComma);
|
||||
|
||||
if (cmd >= 'a') // 'A' < 'a'. lower case for relative
|
||||
{
|
||||
x += _lastPoint.X;
|
||||
y += _lastPoint.Y;
|
||||
}
|
||||
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
private bool ReadToken()
|
||||
{
|
||||
SkipWhiteSpace(!AllowComma);
|
||||
|
||||
// Check for end of string
|
||||
if (More())
|
||||
{
|
||||
_token = _pathString[_curIndex++];
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool More()
|
||||
{
|
||||
return _curIndex < _pathLength;
|
||||
}
|
||||
|
||||
// Skip white space, one comma if allowed
|
||||
private bool SkipWhiteSpace(bool allowComma)
|
||||
{
|
||||
bool commaMet = false;
|
||||
|
||||
while (More())
|
||||
{
|
||||
char ch = _pathString[_curIndex];
|
||||
|
||||
switch (ch)
|
||||
{
|
||||
case ' ':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\t': // SVG whitespace
|
||||
break;
|
||||
|
||||
case ',':
|
||||
if (allowComma)
|
||||
{
|
||||
commaMet = true;
|
||||
allowComma = false; // one comma only
|
||||
}
|
||||
else
|
||||
{
|
||||
ThrowBadToken();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Avoid calling IsWhiteSpace for ch in (' ' .. 'z']
|
||||
if (((ch > ' ') && (ch <= 'z')) || !Char.IsWhiteSpace(ch))
|
||||
{
|
||||
return commaMet;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
_curIndex++;
|
||||
}
|
||||
|
||||
return commaMet;
|
||||
}
|
||||
|
||||
private void ThrowBadToken()
|
||||
{
|
||||
throw new FormatException(string.Format("Unexpected character in path '{0}' at position {1}", _pathString, _curIndex - 1));
|
||||
}
|
||||
|
||||
internal static char GetNumericListSeparator(IFormatProvider provider)
|
||||
{
|
||||
var numericSeparator = ',';
|
||||
|
||||
// Get the NumberFormatInfo out of the provider, if possible
|
||||
// If the IFormatProvider doesn't not contain a NumberFormatInfo, then
|
||||
// this method returns the current culture's NumberFormatInfo.
|
||||
var numberFormat = NumberFormatInfo.GetInstance(provider);
|
||||
|
||||
// Is the decimal separator is the same as the list separator?
|
||||
// If so, we use the ";".
|
||||
if ((numberFormat.NumberDecimalSeparator.Length > 0) && (numericSeparator == numberFormat.NumberDecimalSeparator[0]))
|
||||
{
|
||||
numericSeparator = ';';
|
||||
}
|
||||
|
||||
return numericSeparator;
|
||||
}
|
||||
|
||||
private string ParseBack(PathGeometry geometry)
|
||||
{
|
||||
var sb = new System.Text.StringBuilder();
|
||||
IFormatProvider provider = new CultureInfo("en-us");
|
||||
|
||||
sb.Append("F" + (geometry.FillRule == FillRule.EvenOdd ? "0" : "1") + " ");
|
||||
|
||||
foreach (PathFigure figure in geometry.Figures)
|
||||
{
|
||||
sb.Append("M " + ((IFormattable)figure.StartPoint).ToString(null, provider) + " ");
|
||||
|
||||
foreach (PathSegment segment in figure.Segments)
|
||||
{
|
||||
char separator = GetNumericListSeparator(provider);
|
||||
|
||||
if (segment is LineSegment)
|
||||
{
|
||||
LineSegment lineSegment = segment as LineSegment;
|
||||
|
||||
sb.Append("L " + ((IFormattable)lineSegment.Point).ToString(null, provider) + " ");
|
||||
}
|
||||
else if (segment is BezierSegment)
|
||||
{
|
||||
BezierSegment bezierSegment = segment as BezierSegment;
|
||||
|
||||
sb.Append(string.Format(provider,
|
||||
"C{1:" + null + "}{0}{2:" + null + "}{0}{3:" + null + "} ",
|
||||
separator,
|
||||
bezierSegment.Point1,
|
||||
bezierSegment.Point2,
|
||||
bezierSegment.Point3
|
||||
));
|
||||
}
|
||||
else if (segment is QuadraticBezierSegment)
|
||||
{
|
||||
QuadraticBezierSegment quadraticBezierSegment = segment as QuadraticBezierSegment;
|
||||
|
||||
sb.Append(String.Format(provider,
|
||||
"Q{1:" + null + "}{0}{2:" + null + "} ",
|
||||
separator,
|
||||
quadraticBezierSegment.Point1,
|
||||
quadraticBezierSegment.Point2));
|
||||
}
|
||||
else if (segment is ArcSegment)
|
||||
{
|
||||
ArcSegment arcSegment = segment as ArcSegment;
|
||||
|
||||
sb.Append(String.Format(provider,
|
||||
"A{1:" + null + "}{0}{2:" + null + "}{0}{3}{0}{4}{0}{5:" + null + "} ",
|
||||
separator,
|
||||
arcSegment.Size,
|
||||
arcSegment.RotationAngle,
|
||||
arcSegment.IsLargeArc ? "1" : "0",
|
||||
arcSegment.SweepDirection == SweepDirection.Clockwise ? "1" : "0",
|
||||
arcSegment.Point));
|
||||
}
|
||||
}
|
||||
|
||||
if (figure.IsClosed)
|
||||
sb.Append("Z");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
40
Others/Live-Charts-master/UwpView/Components/IFondeable.cs
Normal file
40
Others/Live-Charts-master/UwpView/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 Windows.UI.Xaml.Media;
|
||||
|
||||
namespace LiveCharts.Uwp.Components
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public interface IFondeable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the point foreround.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The point foreround.
|
||||
/// </value>
|
||||
Brush PointForeround { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace LiveCharts.Uwp.Components.MultiBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of <see cref="DependencyObject"/> instances of a specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items in the collection.</typeparam>
|
||||
public class DependencyObjectCollection<T> : DependencyObjectCollection, INotifyCollectionChanged
|
||||
where T : DependencyObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when items in the collection are added, removed, or replaced.
|
||||
/// </summary>
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||
|
||||
private readonly List<T> _oldItems = new List<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DependencyObjectCollection{T}" /> class.
|
||||
/// </summary>
|
||||
public DependencyObjectCollection()
|
||||
{
|
||||
VectorChanged += DependencyObjectCollectionVectorChanged;
|
||||
}
|
||||
|
||||
private void DependencyObjectCollectionVectorChanged(IObservableVector<DependencyObject> sender, IVectorChangedEventArgs e)
|
||||
{
|
||||
var index = (int)e.Index;
|
||||
|
||||
switch (e.CollectionChange)
|
||||
{
|
||||
case CollectionChange.Reset:
|
||||
foreach (var item in this)
|
||||
{
|
||||
VerifyType(item);
|
||||
}
|
||||
|
||||
RaiseCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
|
||||
_oldItems.Clear();
|
||||
|
||||
break;
|
||||
|
||||
case CollectionChange.ItemInserted:
|
||||
VerifyType(this[index]);
|
||||
|
||||
RaiseCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, this[index], index));
|
||||
|
||||
_oldItems.Insert(index, (T)this[index]);
|
||||
|
||||
break;
|
||||
|
||||
case CollectionChange.ItemRemoved:
|
||||
RaiseCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, _oldItems[index], index));
|
||||
|
||||
_oldItems.RemoveAt(index);
|
||||
|
||||
break;
|
||||
|
||||
case CollectionChange.ItemChanged:
|
||||
VerifyType(this[index]);
|
||||
|
||||
RaiseCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, this[index], _oldItems[index]));
|
||||
|
||||
_oldItems[index] = (T)this[index];
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="CollectionChanged"/> event with the provided event data.
|
||||
/// </summary>
|
||||
/// <param name="eventArgs">The event data.</param>
|
||||
protected void RaiseCollectionChanged(NotifyCollectionChangedEventArgs eventArgs)
|
||||
{
|
||||
var eventHandler = CollectionChanged;
|
||||
|
||||
if (eventHandler != null)
|
||||
{
|
||||
eventHandler(this, eventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
private void VerifyType(DependencyObject item)
|
||||
{
|
||||
if (!(item is T))
|
||||
{
|
||||
throw new InvalidOperationException("Invalid item type added to collection");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Markup;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
|
||||
namespace LiveCharts.Uwp.Components.MultiBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// The behavior that enables multiple binding.
|
||||
/// </summary>
|
||||
[ContentProperty(Name = "Items")]
|
||||
[TypeConstraint(typeof(FrameworkElement))]
|
||||
public class MultiBindingBehavior : Behavior<FrameworkElement>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="MultiBindingItem"/> collection within this <see cref="MultiBindingBehavior"/> instance.
|
||||
/// </summary>
|
||||
/// <value>One or more <see cref="MultiBindingItem"/> objects.</value>
|
||||
public MultiBindingItemCollection Items
|
||||
{
|
||||
get { return (MultiBindingItemCollection)GetValue(ItemsProperty); }
|
||||
private set { SetValue(ItemsProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the <see cref="Items" /> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ItemsProperty =
|
||||
DependencyProperty.Register(nameof(Items), typeof(MultiBindingItemCollection), typeof(MultiBindingBehavior), null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path to the binding source property.
|
||||
/// </summary>
|
||||
/// <value>The path to the binding source property.</value>
|
||||
public string PropertyName
|
||||
{
|
||||
get { return (string)GetValue(PropertyNameProperty); }
|
||||
set { SetValue(PropertyNameProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the <see cref="PropertyName" /> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PropertyNameProperty =
|
||||
DependencyProperty.Register(nameof(PropertyName), typeof(string), typeof(MultiBindingBehavior), new PropertyMetadata(null, OnPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the converter to use to convert the source values to or from the target value.
|
||||
/// </summary>
|
||||
/// <value>A resource reference to a class that implements the <see cref="IValueConverter"/> interface, which includes implementations of the <see cref="IValueConverter.Convert"/> and <see cref="IValueConverter.ConvertBack"/> methods.</value>
|
||||
public IValueConverter Converter
|
||||
{
|
||||
get { return (IValueConverter)GetValue(ConverterProperty); }
|
||||
set { SetValue(ConverterProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the <see cref="Converter" /> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ConverterProperty =
|
||||
DependencyProperty.Register(nameof(Converter), typeof(IValueConverter), typeof(MultiBindingBehavior), new PropertyMetadata(null, OnPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional parameter to pass to the converter as additional information.
|
||||
/// </summary>
|
||||
/// <value>A value of the type expected by the converter, which might be an object element or a string depending on the definition and XAML capabilities both of the property type being used and of the implementation of the converter.</value>
|
||||
public object ConverterParameter
|
||||
{
|
||||
get { return GetValue(ConverterParameterProperty); }
|
||||
set { SetValue(ConverterParameterProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the <see cref="ConverterParameter" /> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ConverterParameterProperty =
|
||||
DependencyProperty.Register(nameof(ConverterParameter), typeof(object), typeof(MultiBindingBehavior), new PropertyMetadata(null, OnPropertyChanged));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value that indicates the direction of the data flow in the binding.
|
||||
/// </summary>
|
||||
/// <value>A value that indicates the direction of the data flow in the binding.</value>
|
||||
public BindingMode Mode
|
||||
{
|
||||
get { return (BindingMode)GetValue(ModeProperty); }
|
||||
set { SetValue(ModeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the <see cref="Mode" /> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ModeProperty =
|
||||
DependencyProperty.Register(nameof(Mode), typeof(BindingMode), typeof(MultiBindingBehavior), new PropertyMetadata(BindingMode.OneWay, OnPropertyChanged));
|
||||
|
||||
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var multiBindingBehavior = (MultiBindingBehavior)d;
|
||||
|
||||
multiBindingBehavior.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MultiBindingBehavior"/> class.
|
||||
/// </summary>
|
||||
public MultiBindingBehavior()
|
||||
{
|
||||
Items = new MultiBindingItemCollection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the behavior is attached to an AssociatedObject.
|
||||
/// </summary>
|
||||
/// <remarks>Override this to hook up functionality to the AssociatedObject.</remarks>
|
||||
protected override void OnAttached()
|
||||
{
|
||||
base.OnAttached();
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (AssociatedObject == null || string.IsNullOrEmpty(PropertyName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var targetProperty = PropertyName;
|
||||
Type targetType;
|
||||
|
||||
if (targetProperty.Contains("."))
|
||||
{
|
||||
var propertyNameParts = targetProperty.Split('.');
|
||||
|
||||
targetType = Type.GetType(string.Format("Windows.UI.Xaml.Controls.{0}, Windows",
|
||||
propertyNameParts[0]));
|
||||
|
||||
targetProperty = propertyNameParts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
targetType = AssociatedObject.GetType();
|
||||
}
|
||||
|
||||
PropertyInfo targetDependencyPropertyField = null;
|
||||
|
||||
while (targetDependencyPropertyField == null && targetType != null)
|
||||
{
|
||||
var targetTypeInfo = targetType.GetTypeInfo();
|
||||
|
||||
targetDependencyPropertyField = targetTypeInfo.GetDeclaredProperty(targetProperty + "Property");
|
||||
|
||||
targetType = targetTypeInfo.BaseType;
|
||||
}
|
||||
|
||||
if (targetDependencyPropertyField == null) return;
|
||||
|
||||
var targetDependencyProperty = (DependencyProperty)targetDependencyPropertyField.GetValue(null);
|
||||
|
||||
var binding = new Binding()
|
||||
{
|
||||
Path = new PropertyPath("Value"),
|
||||
Source = Items,
|
||||
Converter = Converter,
|
||||
ConverterParameter = ConverterParameter,
|
||||
Mode = Mode
|
||||
};
|
||||
|
||||
BindingOperations.SetBinding(AssociatedObject, targetDependencyProperty, binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace LiveCharts.Uwp.Components.MultiBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// A multiple binding item.
|
||||
/// </summary>
|
||||
public class MultiBindingItem : DependencyObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the binding value.
|
||||
/// </summary>
|
||||
/// <value>The binding value.</value>
|
||||
public object Value
|
||||
{
|
||||
get { return GetValue(ValueProperty); }
|
||||
set { SetValue(ValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the <see cref="Value" /> dependency property.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ValueProperty =
|
||||
DependencyProperty.Register(nameof(Value), typeof(object), typeof(MultiBindingItem), new PropertyMetadata(null, OnValueChanged));
|
||||
|
||||
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var multiBindingItem = (MultiBindingItem)d;
|
||||
|
||||
multiBindingItem.Update();
|
||||
}
|
||||
|
||||
internal MultiBindingItemCollection Parent { get; set; }
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var parent = Parent;
|
||||
|
||||
parent?.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace LiveCharts.Uwp.Components.MultiBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of <see cref="MultiBindingBehavior" />.
|
||||
/// </summary>
|
||||
public class MultiBindingItemCollection : DependencyObjectCollection<MultiBindingItem>
|
||||
{
|
||||
private bool _updating;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the multiple binding value.
|
||||
/// </summary>
|
||||
/// <value>The multiple binding value.</value>
|
||||
public object[] Value
|
||||
{
|
||||
get { return (object[])GetValue(ValueProperty); }
|
||||
set { SetValue(ValueProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the <see cref="Value" /> dependency property.
|
||||
/// </summary>
|
||||
internal static readonly DependencyProperty ValueProperty =
|
||||
DependencyProperty.Register(nameof(Value), typeof(object[]), typeof(MultiBindingItemCollection), new PropertyMetadata(null, OnValueChanged));
|
||||
|
||||
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var multiBindingItemCollection = (MultiBindingItemCollection)d;
|
||||
|
||||
multiBindingItemCollection.UpdateSource();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MultiBindingItemCollection"/> class.
|
||||
/// </summary>
|
||||
public MultiBindingItemCollection()
|
||||
{
|
||||
CollectionChanged += OnCollectionChanged;
|
||||
}
|
||||
|
||||
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.OldItems != null)
|
||||
{
|
||||
foreach (MultiBindingItem item in e.OldItems)
|
||||
{
|
||||
item.Parent = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (e.NewItems != null)
|
||||
{
|
||||
foreach (MultiBindingItem item in e.NewItems)
|
||||
{
|
||||
item.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
internal void Update()
|
||||
{
|
||||
if (_updating)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_updating = true;
|
||||
|
||||
Value = this
|
||||
.OfType<MultiBindingItem>()
|
||||
.Select(x => x.Value)
|
||||
.ToArray();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_updating = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSource()
|
||||
{
|
||||
if (_updating)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_updating = true;
|
||||
|
||||
for (var index = 0; index < this.Count; index++)
|
||||
{
|
||||
var multiBindingItem = this[index] as MultiBindingItem;
|
||||
|
||||
if (multiBindingItem != null)
|
||||
{
|
||||
multiBindingItem.Value = Value[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_updating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace LiveCharts.Uwp.Components.MultiBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IValueConverter"/> abstract implementation to be used with the <see cref="MultiBindingBehavior"/>.
|
||||
/// </summary>
|
||||
public abstract class MultiValueConverterBase : DependencyObject, IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Modifies the source data before passing it to the target for display in the UI.
|
||||
/// </summary>
|
||||
/// <returns>The value to be passed to the target dependency property.</returns>
|
||||
/// <param name="values">The source data being passed to the target.</param>
|
||||
/// <param name="targetType">The <see cref="T:System.Type"/> of data expected by the target dependency property.</param>
|
||||
/// <param name="parameter">An optional parameter to be used in the converter logic.</param>
|
||||
/// <param name="culture">The culture of the conversion.</param>
|
||||
public abstract object Convert(object[] values, Type targetType, object parameter, CultureInfo culture);
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the target data before passing it to the source object. This method is called only in <see cref="F:System.Windows.Data.BindingMode.TwoWay"/> bindings.
|
||||
/// </summary>
|
||||
/// <returns>The value to be passed to the source object.</returns>
|
||||
/// <param name="value">The target data being passed to the source.</param>
|
||||
/// <param name="targetType">The <see cref="T:System.Type"/> of data expected by the source object.</param>
|
||||
/// <param name="parameter">An optional parameter to be used in the converter logic.</param>
|
||||
/// <param name="culture">The culture of the conversion.</param>
|
||||
public abstract object[] ConvertBack(object value, Type targetType, object parameter, CultureInfo culture);
|
||||
|
||||
object IValueConverter.Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var cultureInfo = !string.IsNullOrEmpty(language) ? new CultureInfo(language) : null;
|
||||
|
||||
return Convert((object[])value, targetType, parameter, cultureInfo);
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var cultureInfo = !string.IsNullOrEmpty(language) ? new CultureInfo(language) : null;
|
||||
|
||||
return ConvertBack(value, targetType, parameter, cultureInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Others/Live-Charts-master/UwpView/Components/TooltipDto.cs
Normal file
76
Others/Live-Charts-master/UwpView/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 Windows.UI.Xaml.Media;
|
||||
|
||||
namespace LiveCharts.Uwp.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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace LiveCharts.Uwp.Converters
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="Windows.UI.Xaml.Data.IValueConverter" />
|
||||
public class StringFormatConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var format = (parameter as string) ?? Format;
|
||||
if (format == null)
|
||||
return value;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(language))
|
||||
{
|
||||
return string.Format(format, value);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var culture = new CultureInfo(language);
|
||||
return string.Format(culture, format, value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return string.Format(format, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the back.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the format.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The format.
|
||||
/// </value>
|
||||
public string Format { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//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.Globalization;
|
||||
using System.Linq;
|
||||
using LiveCharts.Helpers;
|
||||
|
||||
namespace LiveCharts.Uwp.Converters
|
||||
{
|
||||
//public class StringCollectionConverter : TypeConverter
|
||||
//{
|
||||
// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
// {
|
||||
// return sourceType == typeof (string) || base.CanConvertFrom(context, sourceType);
|
||||
// }
|
||||
|
||||
// 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);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public class NumericChartValuesConverter : TypeConverter
|
||||
//{
|
||||
// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
// {
|
||||
// return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
// }
|
||||
|
||||
// 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((string) d, CultureInfo.InvariantCulture))
|
||||
// .AsChartValues();
|
||||
// }
|
||||
// return base.ConvertFrom(context, culture, value);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
74
Others/Live-Charts-master/UwpView/DefaultAxes.cs
Normal file
74
Others/Live-Charts-master/UwpView/DefaultAxes.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a collection of already defined axes.
|
||||
/// </summary>
|
||||
public static class DefaultAxes
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns default axis
|
||||
/// </summary>
|
||||
public static AxesCollection DefaultAxis => new AxesCollection {new Axis()};
|
||||
|
||||
/// <summary>
|
||||
/// Return an axis without separators at all
|
||||
/// </summary>
|
||||
public static AxesCollection CleanAxis => new AxesCollection
|
||||
{
|
||||
new Axis
|
||||
{
|
||||
IsEnabled = false,
|
||||
Separator = CleanSeparator
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Returns an axis that only displays a line for zero
|
||||
/// </summary>
|
||||
public static AxesCollection OnlyZerosAxis => 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 => new Separator
|
||||
{
|
||||
Visibility = Visibility.Collapsed
|
||||
};
|
||||
}
|
||||
}
|
||||
67
Others/Live-Charts-master/UwpView/DefaultGeoMapTooltip.xaml
Normal file
67
Others/Live-Charts-master/UwpView/DefaultGeoMapTooltip.xaml
Normal file
@@ -0,0 +1,67 @@
|
||||
<!--
|
||||
|
||||
//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.Uwp.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:uwp="using:LiveCharts.Uwp"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:multiBinding="using:LiveCharts.Uwp.Components.MultiBinding"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300"
|
||||
d:DataContext="{d:DesignInstance uwp:DefaultGeoMapTooltip}"
|
||||
BorderThickness="1.3">
|
||||
<UserControl.Background>
|
||||
<SolidColorBrush Color="#202020" Opacity=".8" />
|
||||
</UserControl.Background>
|
||||
<UserControl.Resources>
|
||||
<uwp:GeoDataLabelConverter x:Key="DataLabelConverter"/>
|
||||
</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">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<multiBinding:MultiBindingBehavior Converter="{StaticResource DataLabelConverter}" PropertyName="Orientation">
|
||||
<multiBinding:MultiBindingItem Value="{Binding GeoData.Value}" />
|
||||
<multiBinding:MultiBindingItem Value="{Binding LabelFormatter}" />
|
||||
</multiBinding:MultiBindingBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</UserControl.Template>
|
||||
</UserControl>
|
||||
165
Others/Live-Charts-master/UwpView/DefaultGeoMapTooltip.xaml.cs
Normal file
165
Others/Live-Charts-master/UwpView/DefaultGeoMapTooltip.xaml.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using LiveCharts.Uwp.Components.MultiBinding;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="Windows.UI.Xaml.Controls.UserControl" />
|
||||
/// <seealso cref="Windows.UI.Xaml.Markup.IComponentConnector" />
|
||||
/// <seealso cref="Windows.UI.Xaml.Markup.IComponentConnector2" />
|
||||
public partial class DefaultGeoMapTooltip
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DefaultGeoMapTooltip"/> class.
|
||||
/// </summary>
|
||||
public DefaultGeoMapTooltip()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The corner radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
|
||||
"CornerRadius", typeof (double), typeof (DefaultGeoMapTooltip), new PropertyMetadata(4d));
|
||||
|
||||
/// <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="LiveCharts.Uwp.Components.MultiBinding.MultiValueConverterBase" />
|
||||
public class GeoDataLabelConverter : MultiValueConverterBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Modifies the source data before passing it to the target for display in the UI.
|
||||
/// </summary>
|
||||
/// <param name="values">The source data being passed to the target.</param>
|
||||
/// <param name="targetType">The <see cref="T:System.Type" /> of data expected by the target dependency property.</param>
|
||||
/// <param name="parameter">An optional parameter to be used in the converter logic.</param>
|
||||
/// <param name="culture">The culture of the conversion.</param>
|
||||
/// <returns>
|
||||
/// The value to be passed to the target dependency property.
|
||||
/// </returns>
|
||||
public override 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>
|
||||
/// Modifies the target data before passing it to the source object. This method is called only in <see cref="F:System.Windows.Data.BindingMode.TwoWay" /> bindings.
|
||||
/// </summary>
|
||||
/// <param name="value">The target data being passed to the source.</param>
|
||||
/// <param name="targetType">The <see cref="T:System.Type" /> of data expected by the source object.</param>
|
||||
/// <param name="parameter">An optional parameter to be used in the converter logic.</param>
|
||||
/// <param name="culture">The culture of the conversion.</param>
|
||||
/// <returns>
|
||||
/// The value to be passed to the source object.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public override Object[] ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
73
Others/Live-Charts-master/UwpView/DefaultGeometry.cs
Normal file
73
Others/Live-Charts-master/UwpView/DefaultGeometry.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
//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.
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains an already defined collection of geometries, useful to set the Series.PointGeomety property
|
||||
/// </summary>
|
||||
public static class DefaultGeometries
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the none.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The none.
|
||||
/// </value>
|
||||
public static PointGeometry None => null;
|
||||
/// <summary>
|
||||
/// Gets the circle.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The circle.
|
||||
/// </value>
|
||||
public static PointGeometry Circle => new PointGeometry("M 0,0 A 180,180 180 1 1 1,1 Z");
|
||||
/// <summary>
|
||||
/// Gets the square.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The square.
|
||||
/// </value>
|
||||
public static PointGeometry Square => new PointGeometry("M 1,1 h -2 v -2 h 2 z");
|
||||
/// <summary>
|
||||
/// Gets the diamond.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The diamond.
|
||||
/// </value>
|
||||
public static PointGeometry Diamond => new PointGeometry("M 1,0 L 2,1 1,2 0,1 z");
|
||||
/// <summary>
|
||||
/// Gets the triangle.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The triangle.
|
||||
/// </value>
|
||||
public static PointGeometry Triangle => new PointGeometry("M 0,1 l 1,1 h -2 Z");
|
||||
/// <summary>
|
||||
/// Gets the cross.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The cross.
|
||||
/// </value>
|
||||
public static PointGeometry Cross => new PointGeometry("M0, 0 L1, 1 M0, 1 l1, -1");
|
||||
}
|
||||
}
|
||||
75
Others/Live-Charts-master/UwpView/DefaultLegend.xaml
Normal file
75
Others/Live-Charts-master/UwpView/DefaultLegend.xaml
Normal file
@@ -0,0 +1,75 @@
|
||||
<!--
|
||||
|
||||
//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.Uwp.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:uwp="using:LiveCharts.Uwp"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:multiBinding="using:LiveCharts.Uwp.Components.MultiBinding"
|
||||
mc:Ignorable="d" x:Name="This">
|
||||
<UserControl.Resources>
|
||||
<uwp:OrientationConverter x:Key="OrientationConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Border>
|
||||
<ItemsControl ItemsSource="{x:Bind Series, Mode=OneWay}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VariableSizedWrapGrid MaxWidth="{Binding MaxWidth, ElementName=This}"
|
||||
MaxHeight="{Binding MaxHeight, ElementName=This}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<multiBinding:MultiBindingBehavior Converter="{StaticResource OrientationConverter}" Mode="OneWay" PropertyName="Orientation">
|
||||
<multiBinding:MultiBindingItem Value="{Binding Orientation, ElementName=This, Mode=OneWay}" />
|
||||
<multiBinding:MultiBindingItem Value="{Binding InternalOrientation, ElementName=This, Mode=OneWay}" />
|
||||
</multiBinding:MultiBindingBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</VariableSizedWrapGrid>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="uwp:SeriesViewModel">
|
||||
<Grid Margin="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Path Width="{Binding BulletSize, ElementName=This}"
|
||||
Height="{Binding BulletSize, ElementName=This}"
|
||||
StrokeThickness="{x:Bind StrokeThickness}"
|
||||
Stroke="{x:Bind Stroke}" Fill="{x:Bind Fill}"
|
||||
Stretch="Fill" Data="{Binding PointGeometry}"/>
|
||||
<TextBlock Grid.Column="1" Margin="4 0" Text="{x:Bind Title}" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
||||
|
||||
|
||||
148
Others/Live-Charts-master/UwpView/DefaultLegend.xaml.cs
Normal file
148
Others/Live-Charts-master/UwpView/DefaultLegend.xaml.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;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using LiveCharts.Uwp.Components.MultiBinding;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of DefaultLegend class
|
||||
/// </summary>
|
||||
public DefaultLegend()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the series displayed in the legend.
|
||||
/// </summary>
|
||||
public List<SeriesViewModel> Series
|
||||
{
|
||||
get { return (List<SeriesViewModel>)GetValue(SeriesProperty); }
|
||||
set { SetValue(SeriesProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for Series. This enables animation, styling, binding, etc...
|
||||
/// <summary>
|
||||
/// The series property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SeriesProperty =
|
||||
DependencyProperty.Register("Series", typeof(List<SeriesViewModel>), typeof(DefaultLegend), new PropertyMetadata(null));
|
||||
|
||||
|
||||
|
||||
/// <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>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="LiveCharts.Uwp.Components.MultiBinding.MultiValueConverterBase" />
|
||||
public class OrientationConverter : MultiValueConverterBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Modifies the source data before passing it to the target for display in the UI.
|
||||
/// </summary>
|
||||
/// <param name="values">The source data being passed to the target.</param>
|
||||
/// <param name="targetType">The <see cref="T:System.Type" /> of data expected by the target dependency property.</param>
|
||||
/// <param name="parameter">An optional parameter to be used in the converter logic.</param>
|
||||
/// <param name="culture">The culture of the conversion.</param>
|
||||
/// <returns>
|
||||
/// The value to be passed to the target dependency property.
|
||||
/// </returns>
|
||||
public override Object Convert(Object[] values, Type targetType, Object parameter, CultureInfo culture)
|
||||
{
|
||||
return (Orientation?)values[0] ?? (Orientation)values[1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the target data before passing it to the source object. This method is called only in <see cref="F:System.Windows.Data.BindingMode.TwoWay" /> bindings.
|
||||
/// </summary>
|
||||
/// <param name="value">The target data being passed to the source.</param>
|
||||
/// <param name="targetType">The <see cref="T:System.Type" /> of data expected by the source object.</param>
|
||||
/// <param name="parameter">An optional parameter to be used in the converter logic.</param>
|
||||
/// <param name="culture">The culture of the conversion.</param>
|
||||
/// <returns>
|
||||
/// The value to be passed to the source object.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public override Object[] ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
84
Others/Live-Charts-master/UwpView/DefaultTooltip.xaml
Normal file
84
Others/Live-Charts-master/UwpView/DefaultTooltip.xaml
Normal file
@@ -0,0 +1,84 @@
|
||||
<!--
|
||||
|
||||
//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.Uwp.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:uwp="using:LiveCharts.Uwp"
|
||||
xmlns:converters="using:LiveCharts.Uwp.Converters"
|
||||
mc:Ignorable="d" x:Name="UserControl"
|
||||
d:DataContext="{d:DesignInstance uwp:DefaultTooltip}"
|
||||
BorderThickness="1.3">
|
||||
<UserControl.Background>
|
||||
<SolidColorBrush Color="#202020" Opacity=".8" />
|
||||
</UserControl.Background>
|
||||
<UserControl.Resources>
|
||||
<uwp:SharedConverter x:Key="SharedConverter"/>
|
||||
<uwp:SharedVisibilityConverter x:Key="SharedVisibilityConverter"/>
|
||||
<uwp:ChartPointLabelConverter x:Key="ChartPointLabelConverter"/>
|
||||
<uwp:ParticipationVisibilityConverter x:Key="ParticipationVisibilityConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Border Background="{x:Bind Background}" CornerRadius="{x:Bind CornerRadius}"
|
||||
BorderThickness="{x:Bind BorderThickness}" Padding="10 5">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="{Binding Data, Converter={StaticResource SharedConverter}}" HorizontalAlignment="Center" FontWeight="Bold"
|
||||
Visibility="{Binding Data, Converter={StaticResource SharedVisibilityConverter}}" />
|
||||
<!-- Grid.IsSharedSizeScope="True"-->
|
||||
<ItemsControl ItemsSource="{Binding Data.Points}" x:Name="ItemsControl">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="uwp:DataPointViewModel">
|
||||
<Grid Margin="2">
|
||||
<Grid.Resources>
|
||||
<converters:StringFormatConverter x:Key="StrFormatConverter" Format="{}{0:P}"/>
|
||||
</Grid.Resources>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Path Width="{Binding ElementName=UserControl, Path=BulletSize}"
|
||||
Height="{Binding ElementName=UserControl, Path=BulletSize}"
|
||||
StrokeThickness="{Binding Series.StrokeThickness}"
|
||||
Stroke="{Binding Series.Stroke}" Fill="{Binding Series.Fill}"
|
||||
Stretch="Fill" Data="{Binding Series.PointGeometry}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Series.Title}" VerticalAlignment="Center" Margin="5 0 0 0"/>
|
||||
|
||||
<TextBlock Grid.Column="2" Text="{Binding ChartPoint, Converter={StaticResource ChartPointLabelConverter}}" Margin="5 0 0 0" VerticalAlignment="Center"/>
|
||||
|
||||
<TextBlock Grid.Column="3" Text="{Binding ChartPoint.Participation, Converter={StaticResource StrFormatConverter}}"
|
||||
VerticalAlignment="Center" Margin="5 0 0 0"
|
||||
Visibility="{Binding DataContext.Data, ElementName=ItemsControl,
|
||||
Converter={StaticResource ParticipationVisibilityConverter}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</UserControl>
|
||||
368
Others/Live-Charts-master/UwpView/DefaultTooltip.xaml.cs
Normal file
368
Others/Live-Charts-master/UwpView/DefaultTooltip.xaml.cs
Normal file
@@ -0,0 +1,368 @@
|
||||
//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.Linq;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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();
|
||||
|
||||
this.SetIfNotSet(ForegroundProperty, new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)));
|
||||
//SetValue(CornerRadiusProperty, new CornerRadius(4d));
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The corner radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
|
||||
"CornerRadius", typeof (CornerRadius), typeof (DefaultTooltip), new PropertyMetadata(new CornerRadius(4d)));
|
||||
/// <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(TooltipSelectionMode.Auto));
|
||||
/// <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 a property value changes.
|
||||
/// </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)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="Windows.UI.Xaml.Data.IValueConverter" />
|
||||
public class SharedConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
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 the back.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="Windows.UI.Xaml.Data.IValueConverter" />
|
||||
public class ChartPointLabelConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var chartPoint = value as ChartPoint;
|
||||
|
||||
return chartPoint?.SeriesView.LabelPoint(chartPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the back.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="Windows.UI.Xaml.Data.IValueConverter" />
|
||||
public class ParticipationVisibilityConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
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 the back.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="Windows.UI.Xaml.Data.IValueConverter" />
|
||||
public class SharedVisibilityConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the specified value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
var v = value as TooltipData;
|
||||
|
||||
if (v == null) return null;
|
||||
|
||||
if (v.SelectionMode == TooltipSelectionMode.OnlySender) return Visibility.Collapsed;
|
||||
|
||||
return v.SharedValue == null ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the back.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="targetType">Type of the target.</param>
|
||||
/// <param name="parameter">The parameter.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
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; }
|
||||
}
|
||||
|
||||
}
|
||||
83
Others/Live-Charts-master/UwpView/Extentions.cs
Normal file
83
Others/Live-Charts-master/UwpView/Extentions.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System.Linq;
|
||||
using Windows.Foundation;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
493
Others/Live-Charts-master/UwpView/Gauge.cs
Normal file
493
Others/Live-Charts-master/UwpView/Gauge.cs
Normal file
@@ -0,0 +1,493 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
/// The gauge chart is useful to display progress or completion.
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
Canvas.SetZIndex(PieBack, 0);
|
||||
Canvas.SetZIndex(Pie, 1);
|
||||
|
||||
PieBack.SetBinding(Shape.FillProperty,
|
||||
new Binding {Path = new PropertyPath("GaugeBackground"), Source = this});
|
||||
PieBack.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding {Path = new PropertyPath("StrokeThickness"), Source = this});
|
||||
PieBack.SetBinding(Shape.StrokeProperty,
|
||||
new Binding {Path = new PropertyPath("Stroke"), Source = this});
|
||||
PieBack.SetBinding(RenderTransformProperty,
|
||||
new Binding { Path = new PropertyPath("GaugeRenderTransform"), Source = this });
|
||||
|
||||
Pie.SetBinding(Shape.StrokeThicknessProperty,
|
||||
new Binding { Path = new PropertyPath("StrokeThickness"), Source = this });
|
||||
Pie.SetBinding(RenderTransformProperty,
|
||||
new Binding { Path = new PropertyPath("GaugeRenderTransform"), Source = this });
|
||||
Pie.Stroke = new SolidColorBrush(Colors.Transparent);
|
||||
|
||||
this.SetIfNotSet(MinHeightProperty, 20d);
|
||||
this.SetIfNotSet(MinWidthProperty, 20d);
|
||||
|
||||
MeasureTextBlock.FontWeight = FontWeights.Bold;
|
||||
|
||||
IsNew = true;
|
||||
|
||||
SizeChanged += (sender, args) =>
|
||||
{
|
||||
IsChartInitialized = true;
|
||||
Update();
|
||||
};
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
private Canvas Canvas { get; }
|
||||
private PieSlice PieBack { get; }
|
||||
private PieSlice Pie { get; }
|
||||
private TextBlock MeasureTextBlock { get; }
|
||||
private TextBlock LeftLabel { get; }
|
||||
private TextBlock RightLabel { get; }
|
||||
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(double.NaN, 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(new SolidColorBrush(Color.FromArgb(255, 222, 222, 222))));
|
||||
/// <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(0d));
|
||||
/// <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(Color.FromArgb(255, 21, 101, 191), 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(Color.FromArgb(255, 100, 180, 245), 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(new SolidColorBrush(Color.FromArgb(255, 21, 101, 191)) { Opacity = .1 }));
|
||||
/// <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(TimeSpan.FromMilliseconds(800)));
|
||||
/// <summary>
|
||||
/// G3ts or sets the gauge animations speed
|
||||
/// </summary>
|
||||
public TimeSpan AnimationsSpeed
|
||||
{
|
||||
get { return (TimeSpan) GetValue(AnimationsSpeedProperty); }
|
||||
set { SetValue(AnimationsSpeedProperty, 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(double.NaN));
|
||||
/// <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;
|
||||
|
||||
var ms = new Size(double.PositiveInfinity, double.PositiveInfinity);
|
||||
Measure(ms);
|
||||
Canvas.Width = Width;
|
||||
Canvas.Height = Height;
|
||||
|
||||
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.Visibility = LabelsVisibility;
|
||||
RightLabel.Visibility = LabelsVisibility;
|
||||
|
||||
t = LeftLabel.ActualHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
LeftLabel.Visibility = Visibility.Collapsed;
|
||||
RightLabel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
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.Height = Canvas.ActualHeight;
|
||||
PieBack.Width = Canvas.ActualWidth;
|
||||
Pie.Height = Canvas.ActualHeight;
|
||||
Pie.Width = Canvas.ActualWidth;
|
||||
|
||||
PieBack.Radius = r;
|
||||
PieBack.InnerRadius = double.IsNaN(InnerRadius) ? r*.6 : InnerRadius;
|
||||
PieBack.RotationAngle = 270;
|
||||
PieBack.WedgeAngle = angle;
|
||||
|
||||
Pie.Radius = PieBack.Radius;
|
||||
Pie.InnerRadius = PieBack.InnerRadius;
|
||||
Pie.RotationAngle = PieBack.RotationAngle;
|
||||
|
||||
Pie.YOffset = top - ActualHeight/2;
|
||||
PieBack.YOffset = top - ActualHeight / 2;
|
||||
|
||||
Canvas.SetTop(LeftLabel, top);
|
||||
Canvas.SetTop(RightLabel, top);
|
||||
LeftLabel.Measure(ms);
|
||||
RightLabel.Measure(ms);
|
||||
Canvas.SetLeft(LeftLabel,
|
||||
Canvas.ActualWidth*.5 -
|
||||
(Pie.InnerRadius + (Pie.Radius - Pie.InnerRadius)*.5 + LeftLabel.DesiredSize.Width*.5));
|
||||
Canvas.SetLeft(RightLabel,
|
||||
Canvas.ActualWidth*.5 +
|
||||
(Pie.InnerRadius + (Pie.Radius - Pie.InnerRadius)*.5 - RightLabel.DesiredSize.Width * .5));
|
||||
|
||||
MeasureTextBlock.FontSize = double.IsNaN(HighFontSize) ? Pie.InnerRadius*.4 : HighFontSize;
|
||||
MeasureTextBlock.Text = (LabelFormatter ?? defFormatter)(Value);
|
||||
|
||||
MeasureTextBlock.Measure(ms);
|
||||
Canvas.SetTop(MeasureTextBlock, top - MeasureTextBlock.DesiredSize.Height*(Uses360Mode ? .5 : 1));
|
||||
Canvas.SetLeft(MeasureTextBlock, ActualWidth/2 - MeasureTextBlock.DesiredSize.Width/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;
|
||||
}
|
||||
|
||||
Pie.BeginDoubleAnimation(nameof(PieSlice.WedgeAngle), completed * angle, AnimationsSpeed);
|
||||
|
||||
if (GaugeActiveFill == null)
|
||||
{
|
||||
((SolidColorBrush)Pie.Fill).BeginColorAnimation(nameof(SolidColorBrush.Color), 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
662
Others/Live-Charts-master/UwpView/GeoMap.cs
Normal file
662
Others/Live-Charts-master/UwpView/GeoMap.cs
Normal file
@@ -0,0 +1,662 @@
|
||||
//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 Windows.Devices.Input;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Maps;
|
||||
using LiveCharts.Uwp.Components;
|
||||
using LiveCharts.Uwp.Components.MultiBinding;
|
||||
using LiveCharts.Uwp.Maps;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using Path = Windows.UI.Xaml.Shapes.Path;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="Windows.UI.Xaml.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("ActualWidth"), Source = this });
|
||||
Canvas.SetBinding(HeightProperty,
|
||||
new Binding { Path = new PropertyPath("ActualHeight"), Source = this });
|
||||
|
||||
Lands = new Dictionary<string, MapData>();
|
||||
|
||||
this.SetIfNotSet(BackgroundProperty, new SolidColorBrush(Color.FromArgb(150, 96, 125, 138)));
|
||||
/*Current*/
|
||||
SetValue(GradientStopCollectionProperty, new GradientStopCollection
|
||||
{
|
||||
new GradientStop()
|
||||
{
|
||||
Color = Color.FromArgb(100, 2, 119, 188),
|
||||
Offset = 0d
|
||||
},
|
||||
new GradientStop()
|
||||
{
|
||||
Color = Color.FromArgb(255, 2, 119, 188),
|
||||
Offset = 1d
|
||||
},
|
||||
});
|
||||
this.SetIfNotSet(HeatMapProperty, new Dictionary<string, double>());
|
||||
/*Current*/
|
||||
SetValue(GeoMapTooltipProperty, new DefaultGeoMapTooltip {Visibility = Visibility.Collapsed}); //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.CreateCanvasStoryBoardAndBegin(l, t, AnimationsSpeed);
|
||||
// }
|
||||
//};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [land click].
|
||||
/// </summary>
|
||||
public event Action<object, MapData> LandClick;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
private Canvas Canvas { get; }
|
||||
private Canvas Map { get; }
|
||||
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; }
|
||||
|
||||
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(new SolidColorBrush(Color.FromArgb(200, 255, 255, 255))));
|
||||
/// <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(1.3d));
|
||||
/// <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(new SolidColorBrush(Color.FromArgb(30, 55, 55, 55))));
|
||||
/// <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(TimeSpan.FromMilliseconds(500)));
|
||||
/// <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() {ScaleX = 1, ScaleY = 1};
|
||||
if (DisableAnimations)
|
||||
{
|
||||
Canvas.SetLeft(Map, OriginalPosition.X);
|
||||
Canvas.SetTop(Map, OriginalPosition.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map.CreateCanvasStoryBoardAndBegin(OriginalPosition.X, 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 (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
|
||||
{
|
||||
Map.Children.Add(new TextBlock
|
||||
{
|
||||
Text = "Designer preview is not currently available",
|
||||
Foreground = new SolidColorBrush(Colors.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() {ScaleX = s, ScaleY = s};
|
||||
|
||||
foreach (var land in map.Data)
|
||||
{
|
||||
var p = new Path
|
||||
{
|
||||
Data = GeometryHelper.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("LandStroke"), Source = this });
|
||||
var behavior = new MultiBindingBehavior()
|
||||
{
|
||||
Converter = new ScaleStrokeConverter(),
|
||||
PropertyName = "StrokeThickness"
|
||||
};
|
||||
behavior.Items.Add(new MultiBindingItem() {Parent = behavior.Items, Value = new Binding() { Path = new PropertyPath("LandStrokeThickness"), Source = this } });
|
||||
behavior.Items.Add(new MultiBindingItem() {Parent = behavior.Items, Value = new Binding() { Path = new PropertyPath("ScaleX"), Source = t } });
|
||||
Interaction.SetBehaviors(p, new BehaviorCollection() {behavior});
|
||||
}
|
||||
|
||||
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("DefaultLandFill"), 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).BeginColorAnimation(nameof(SolidColorBrush.Color), color, AnimationsSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void POnMouseDown(object sender, PointerRoutedEventArgs 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.Collapsed;//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.FromArgb(255, 0, 0, 0), to = Color.FromArgb(255, 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="LiveCharts.Uwp.Components.MultiBinding.MultiValueConverterBase" />
|
||||
public class ScaleStrokeConverter : MultiValueConverterBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Modifies the source data before passing it to the target for display in the UI.
|
||||
/// </summary>
|
||||
/// <param name="values">The source data being passed to the target.</param>
|
||||
/// <param name="targetType">The <see cref="T:System.Type" /> of data expected by the target dependency property.</param>
|
||||
/// <param name="parameter">An optional parameter to be used in the converter logic.</param>
|
||||
/// <param name="culture">The culture of the conversion.</param>
|
||||
/// <returns>
|
||||
/// The value to be passed to the target dependency property.
|
||||
/// </returns>
|
||||
public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (double) values[0]/(double) values[1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the target data before passing it to the source object. This method is called only in <see cref="F:System.Windows.Data.BindingMode.TwoWay" /> bindings.
|
||||
/// </summary>
|
||||
/// <param name="value">The target data being passed to the source.</param>
|
||||
/// <param name="targetType">The <see cref="T:System.Type" /> of data expected by the source object.</param>
|
||||
/// <param name="parameter">An optional parameter to be used in the converter logic.</param>
|
||||
/// <param name="culture">The culture of the conversion.</param>
|
||||
/// <returns>
|
||||
/// The value to be passed to the source object.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public override Object[] ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Others/Live-Charts-master/UwpView/HeatColorRange.xaml
Normal file
13
Others/Live-Charts-master/UwpView/HeatColorRange.xaml
Normal file
@@ -0,0 +1,13 @@
|
||||
<UserControl x:Class="LiveCharts.Uwp.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"
|
||||
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>
|
||||
83
Others/Live-Charts-master/UwpView/HeatColorRange.xaml.cs
Normal file
83
Others/Live-Charts-master/UwpView/HeatColorRange.xaml.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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)
|
||||
{
|
||||
var brush = Background as LinearGradientBrush;
|
||||
if (brush == null || brush.GradientStops != 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
331
Others/Live-Charts-master/UwpView/HeatSeries.cs
Normal file
331
Others/Live-Charts-master/UwpView/HeatSeries.cs
Normal file
@@ -0,0 +1,331 @@
|
||||
//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 Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Helpers;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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(true, 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;
|
||||
|
||||
Canvas.SetZIndex(pbv.Rectangle, Canvas.GetZIndex(pbv.Rectangle));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = new SolidColorBrush(Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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 =>
|
||||
{
|
||||
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("FontFamily"), Source = this});
|
||||
ColorRangeControl.SetBinding(TextBlock.FontSizeProperty,
|
||||
new Binding {Path = new PropertyPath("FontSize"), Source = this});
|
||||
ColorRangeControl.SetBinding(TextBlock.FontStretchProperty,
|
||||
new Binding {Path = new PropertyPath("FontStretch"), Source = this});
|
||||
ColorRangeControl.SetBinding(TextBlock.FontStyleProperty,
|
||||
new Binding {Path = new PropertyPath("FontStyle"), Source = this});
|
||||
ColorRangeControl.SetBinding(TextBlock.FontWeightProperty,
|
||||
new Binding {Path = new PropertyPath("FontWeight"), Source = this});
|
||||
ColorRangeControl.SetBinding(TextBlock.ForegroundProperty,
|
||||
new Binding {Path = new PropertyPath("Foreground"), Source = this});
|
||||
ColorRangeControl.SetBinding(VisibilityProperty,
|
||||
new Binding {Path = new PropertyPath("Visibility"), 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;
|
||||
|
||||
if (DrawsHeatRange)
|
||||
{
|
||||
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()
|
||||
{
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 0d);
|
||||
//this.SetIfNotSet(ForegroundProperty, new SolidColorBrush(Colors.White));
|
||||
//this.SetIfNotSet(StrokeProperty, new SolidColorBrush(Colors.White));
|
||||
this.SetIfNotSet(GradientStopCollectionProperty, new GradientStopCollection());
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => x.Weight.ToString(CultureInfo.InvariantCulture);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.4;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the series colors if they are not set
|
||||
/// </summary>
|
||||
public override void InitializeColors()
|
||||
{
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
var nextColor = uwpfChart.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
|
||||
}
|
||||
}
|
||||
40
Others/Live-Charts-master/UwpView/IChartLegend.cs
Normal file
40
Others/Live-Charts-master/UwpView/IChartLegend.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.Collections.Generic;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public interface IChartLegend
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the series.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The series.
|
||||
/// </value>
|
||||
List<SeriesViewModel> Series { get; set; }
|
||||
}
|
||||
}
|
||||
48
Others/Live-Charts-master/UwpView/IChartTooltip.cs
Normal file
48
Others/Live-Charts-master/UwpView/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.Uwp
|
||||
{
|
||||
/// <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/UwpView/LineSegmentSplitter.cs
Normal file
42
Others/Live-Charts-master/UwpView/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 Windows.UI.Xaml.Media;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
internal class LineSegmentSplitter
|
||||
{
|
||||
public LineSegmentSplitter()
|
||||
{
|
||||
Bottom = new LineSegment();
|
||||
Left = new LineSegment();
|
||||
Right = new LineSegment();
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
483
Others/Live-Charts-master/UwpView/LineSeries.cs
Normal file
483
Others/Live-Charts-master/UwpView/LineSeries.cs
Normal file
@@ -0,0 +1,483 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Helpers;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Components;
|
||||
using LiveCharts.Uwp.Points;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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(8d, 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 PointForeroundProperty = DependencyProperty.Register(
|
||||
"PointForeround", typeof (Brush), typeof (LineSeries),
|
||||
new PropertyMetadata(new SolidColorBrush(Windows.UI.Colors.White)));
|
||||
/// <summary>
|
||||
/// Gets or sets the point shape foreground.
|
||||
/// </summary>
|
||||
public Brush PointForeround
|
||||
{
|
||||
get { return (Brush) GetValue(PointForeroundProperty); }
|
||||
set { SetValue(PointForeroundProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The line smoothness property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LineSmoothnessProperty = DependencyProperty.Register(
|
||||
"LineSmoothness", typeof (double), typeof (LineSeries),
|
||||
new PropertyMetadata(.7d, 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;
|
||||
Canvas.SetZIndex(Path, Canvas.GetZIndex(this));
|
||||
return;
|
||||
}
|
||||
|
||||
IsPathInitialized = true;
|
||||
|
||||
Path = new Path
|
||||
{
|
||||
Stroke = Stroke,
|
||||
StrokeThickness = StrokeThickness,
|
||||
Fill = Fill,
|
||||
Visibility = Visibility,
|
||||
StrokeDashArray = StrokeDashArray
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(Path, Canvas.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 = new SolidColorBrush(Windows.UI.Colors.Transparent),
|
||||
StrokeThickness = 0,
|
||||
Width = mhr,
|
||||
Height = mhr
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (Math.Abs(PointGeometrySize) > 0.1 && pbv.Shape == null)
|
||||
{
|
||||
pbv.Shape = new Path
|
||||
{
|
||||
Stretch = Stretch.Fill,
|
||||
StrokeThickness = StrokeThickness
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Shape);
|
||||
}
|
||||
|
||||
if (pbv.Shape != null)
|
||||
{
|
||||
pbv.Shape.Fill = PointForeround;
|
||||
pbv.Shape.Stroke = Stroke;
|
||||
pbv.Shape.StrokeThickness = StrokeThickness;
|
||||
pbv.Shape.Width = PointGeometrySize;
|
||||
pbv.Shape.Height = PointGeometrySize;
|
||||
pbv.Shape.Data = PointGeometry.Parse();
|
||||
pbv.Shape.Visibility = Visibility;
|
||||
Canvas.SetZIndex(pbv.Shape, Canvas.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()
|
||||
{
|
||||
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 =>
|
||||
{
|
||||
p.View?.RemoveFromView(Model.Chart);
|
||||
});
|
||||
if (Path != null) Path.Visibility = Visibility.Collapsed;
|
||||
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.BeginPointAnimation(nameof(PathFigure.StartPoint),
|
||||
new Point(location.X, areaLimit), Model.Chart.View.AnimationsSpeed);
|
||||
|
||||
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.BeginPointAnimation(nameof(LineSegment.Point), 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.BeginPointAnimation(nameof(LineSegment.Point), 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.BeginPointAnimation(nameof(LineSegment.Point), 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.BeginPointAnimation(nameof(LineSegment.Point), new Point(location.X, areaLimit), animSpeed);
|
||||
Figure.Segments.Insert(atIndex, splitter.Right);
|
||||
|
||||
splitter.IsNew = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.15;
|
||||
Splitters = new List<LineSegmentSplitter>();
|
||||
|
||||
IsNew = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
77
Others/Live-Charts-master/UwpView/LogarithmicAxis.cs
Normal file
77
Others/Live-Charts-master/UwpView/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 Windows.UI.Xaml;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
/// An Logarithmic Axis of a chart
|
||||
/// </summary>
|
||||
/// <seealso cref="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); }
|
||||
}
|
||||
}
|
||||
}
|
||||
81
Others/Live-Charts-master/UwpView/Maps/MapResolver.cs
Normal file
81
Others/Live-Charts-master/UwpView/Maps/MapResolver.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
//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.IO;
|
||||
using System.Xml;
|
||||
using LiveCharts.Maps;
|
||||
|
||||
namespace LiveCharts.Uwp.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
247
Others/Live-Charts-master/UwpView/OhlcSeries.cs
Normal file
247
Others/Live-Charts-master/UwpView/OhlcSeries.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
//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 Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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(35d));
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum with of a point, a point will be capped to this width.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The maximum width of the column.
|
||||
/// </value>
|
||||
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(new SolidColorBrush(Color.FromArgb(255, 254, 178, 0))));
|
||||
/// <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(new SolidColorBrush(Color.FromArgb(255, 238, 83, 80))));
|
||||
/// <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 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 = (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 = Canvas.GetZIndex(this);
|
||||
Canvas.SetZIndex(pbv.HighToLowLine, i);
|
||||
Canvas.SetZIndex(pbv.CloseLine, i);
|
||||
Canvas.SetZIndex(pbv.OpenLine, i);
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = new SolidColorBrush(Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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()
|
||||
{
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 2.5d);
|
||||
//this.SetIfNotSet(MaxColumnWidthProperty, 35d);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x =>
|
||||
$"O: {x.Open}, H: {x.High}, L: {x.Low} C: {x.Close}";
|
||||
/*Current*/
|
||||
SetValue(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
118
Others/Live-Charts-master/UwpView/PieChart.cs
Normal file
118
Others/Live-Charts-master/UwpView/PieChart.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.UI.Xaml;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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);
|
||||
|
||||
this.SetIfNotSet(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
193
Others/Live-Charts-master/UwpView/PieSeries.cs
Normal file
193
Others/Live-Charts-master/UwpView/PieSeries.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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;
|
||||
Canvas.SetZIndex(pbv.Slice, Canvas.GetZIndex(this));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new PieSlice
|
||||
{
|
||||
Fill = new SolidColorBrush(Windows.UI.Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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()
|
||||
{
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 2d);
|
||||
//this.SetIfNotSet(StrokeProperty, new SolidColorBrush(Windows.UI.Colors.White));
|
||||
//this.SetIfNotSet(ForegroundProperty, new SolidColorBrush(Windows.UI.Colors.White));
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
55
Others/Live-Charts-master/UwpView/PointGeometry.cs
Normal file
55
Others/Live-Charts-master/UwpView/PointGeometry.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
//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.
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class PointGeometry
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PointGeometry"/> class.
|
||||
/// </summary>
|
||||
public PointGeometry()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PointGeometry"/> class.
|
||||
/// </summary>
|
||||
/// <param name="data">The data.</param>
|
||||
public PointGeometry(string data)
|
||||
{
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the data.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The data.
|
||||
/// </value>
|
||||
public string Data { get; set; }
|
||||
}
|
||||
}
|
||||
162
Others/Live-Charts-master/UwpView/Points/CandlePointView.cs
Normal file
162
Others/Live-Charts-master/UwpView/Points/CandlePointView.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 Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.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 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.CreateCanvasStoryBoardAndBegin(cx, cy, animSpeed);
|
||||
}
|
||||
|
||||
var x1Animation = AnimationsHelper.CreateDouble(center, animSpeed, "Line.X1");
|
||||
var x2Animation = AnimationsHelper.CreateDouble(center, animSpeed, "Line.X2");
|
||||
AnimationsHelper.CreateStoryBoard(HighToLowLine, x1Animation, x2Animation);
|
||||
|
||||
var y1Animation = AnimationsHelper.CreateDouble(High, animSpeed, "Line.Y1");
|
||||
var y2Animation = AnimationsHelper.CreateDouble(Low, animSpeed, "Line.Y2");
|
||||
AnimationsHelper.CreateStoryBoardAndBegin(HighToLowLine, y1Animation, y2Animation);
|
||||
|
||||
OpenToCloseRectangle.BeginDoubleAnimation("(Canvas.Left)", Left, animSpeed);
|
||||
OpenToCloseRectangle.BeginDoubleAnimation("(Canvas.Top)", Math.Min(Open, Close), animSpeed);
|
||||
|
||||
OpenToCloseRectangle.BeginDoubleAnimation("Width", Width, animSpeed);
|
||||
OpenToCloseRectangle.BeginDoubleAnimation("Height", 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 > 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/UwpView/Points/ColumnPointView.cs
Normal file
205
Others/Live-Charts-master/UwpView/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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.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 {Angle = 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.CreateCanvasStoryBoardAndBegin(getX(), getY(), animSpeed);
|
||||
}
|
||||
|
||||
Rectangle.BeginDoubleAnimation("(Canvas.Left)", Data.Left, animSpeed);
|
||||
Rectangle.BeginDoubleAnimation("(Canvas.Top)", Data.Top, animSpeed);
|
||||
|
||||
Rectangle.BeginDoubleAnimation("(Canvas.Height)", Data.Width, animSpeed);
|
||||
Rectangle.BeginDoubleAnimation(nameof(FrameworkElement.Height), 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();
|
||||
|
||||
if (copy == null) return;
|
||||
|
||||
copy.Opacity -= .15;
|
||||
Rectangle.Fill = copy;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
if (Rectangle?.Fill == null) return;
|
||||
|
||||
Rectangle.Fill.Opacity += .15;
|
||||
|
||||
if (point.Fill != null)
|
||||
{
|
||||
Rectangle.Fill = (Brush) point.Fill;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle.Fill = ((Series) point.SeriesView).Fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
105
Others/Live-Charts-master/UwpView/Points/HeatPoint.cs
Normal file
105
Others/Live-Charts-master/UwpView/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 Windows.UI;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.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.BeginColorAnimation(nameof(SolidColorBrush.Color), 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,216 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.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);
|
||||
|
||||
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
|
||||
{
|
||||
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 (DataLabel != null)
|
||||
{
|
||||
Canvas.SetTop(DataLabel, y);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X - DataLabel.ActualWidth * .5);
|
||||
}
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetTop(Shape, y);
|
||||
Canvas.SetLeft(Shape, current.ChartLocation.X - Shape.Width*.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
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
Segment.BeginPointAnimation(nameof(BezierSegment.Point1), Data.Point1.AsPoint(), animSpeed);
|
||||
Segment.BeginPointAnimation(nameof(BezierSegment.Point2), Data.Point2.AsPoint(), animSpeed);
|
||||
Segment.BeginPointAnimation(nameof(BezierSegment.Point3), Data.Point3.AsPoint(), animSpeed);
|
||||
|
||||
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.CreateCanvasStoryBoardAndBegin(current.ChartLocation.X - Shape.Width*.5,
|
||||
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.CreateCanvasStoryBoardAndBegin(xl, 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.PointForeround
|
||||
: (Brush) point.Fill;
|
||||
lineSeries.Path.StrokeThickness = lineSeries.StrokeThickness;
|
||||
}
|
||||
}
|
||||
}
|
||||
171
Others/Live-Charts-master/UwpView/Points/OhlcPointView.cs
Normal file
171
Others/Live-Charts-master/UwpView/Points/OhlcPointView.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
//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 Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.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 (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 (DataLabel != null && double.IsNaN(Canvas.GetLeft(DataLabel)))
|
||||
{
|
||||
Canvas.SetTop(DataLabel, current.ChartLocation.Y);
|
||||
Canvas.SetLeft(DataLabel, current.ChartLocation.X);
|
||||
}
|
||||
|
||||
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.CreateCanvasStoryBoardAndBegin(cx, cy, animSpeed);
|
||||
}
|
||||
|
||||
HighToLowLine.BeginDoubleAnimation("Line.X1", center, animSpeed);
|
||||
HighToLowLine.BeginDoubleAnimation("Line.X2", center, animSpeed);
|
||||
OpenLine.BeginDoubleAnimation("Line.X1", Left, animSpeed);
|
||||
OpenLine.BeginDoubleAnimation("Line.X2", center, animSpeed);
|
||||
CloseLine.BeginDoubleAnimation("Line.X1", center, animSpeed);
|
||||
CloseLine.BeginDoubleAnimation("Line.X2", center, animSpeed);
|
||||
|
||||
HighToLowLine.CreateY1Y2StoryBoardAndBegin(High, Low, animSpeed);
|
||||
OpenLine.CreateY1Y2StoryBoardAndBegin(Open, Open, animSpeed);
|
||||
CloseLine.CreateY1Y2StoryBoardAndBegin(Close, 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)
|
||||
{
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
171
Others/Live-Charts-master/UwpView/Points/PiePointView.cs
Normal file
171
Others/Live-Charts-master/UwpView/Points/PiePointView.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.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)
|
||||
{
|
||||
Slice.Width = chart.DrawMargin.Width;
|
||||
Slice.Height = chart.DrawMargin.Height;
|
||||
|
||||
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;
|
||||
|
||||
hs.Width = chart.DrawMargin.Width;
|
||||
hs.Height = chart.DrawMargin.Height;
|
||||
hs.WedgeAngle = Wedge;
|
||||
hs.RotationAngle = Rotation;
|
||||
hs.InnerRadius = InnerRadius;
|
||||
hs.Radius = Radius;
|
||||
}
|
||||
|
||||
Slice.Width = chart.DrawMargin.Width;
|
||||
Slice.Height = chart.DrawMargin.Height;
|
||||
|
||||
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)
|
||||
{
|
||||
DataLabel.UpdateLayout();
|
||||
|
||||
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.CreateCanvasStoryBoardAndBegin(lx, ly, animSpeed);
|
||||
}
|
||||
|
||||
Slice.BeginDoubleAnimation("(Canvas.Left)", chart.DrawMargin.Width / 2, animSpeed);
|
||||
Slice.BeginDoubleAnimation("(Canvas.Top)", chart.DrawMargin.Height / 2, animSpeed);
|
||||
Slice.BeginDoubleAnimation(nameof(PieSlice.InnerRadius), InnerRadius, animSpeed);
|
||||
Slice.BeginDoubleAnimation(nameof(PieSlice.Radius), Radius, animSpeed);
|
||||
Slice.BeginDoubleAnimation(nameof(PieSlice.WedgeAngle), Wedge, animSpeed);
|
||||
Slice.BeginDoubleAnimation(nameof(PieSlice.RotationAngle), 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)
|
||||
{
|
||||
Slice.Fill = Slice.Fill.Clone();
|
||||
|
||||
if (Slice?.Fill != null)
|
||||
{
|
||||
Slice.Fill.Opacity -= .15;
|
||||
}
|
||||
|
||||
if (Slice != null)
|
||||
{
|
||||
var pieChart = (PieChart) point.SeriesView.Model.Chart.View;
|
||||
|
||||
Slice.BeginDoubleAnimation(nameof(PieSlice.PushOut), 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.BeginDoubleAnimation(nameof(Slice.PushOut), OriginalPushOut,
|
||||
point.SeriesView.Model.Chart.View.AnimationsSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
298
Others/Live-Charts-master/UwpView/Points/PieSlice.cs
Normal file
298
Others/Live-Charts-master/UwpView/Points/PieSlice.cs
Normal file
@@ -0,0 +1,298 @@
|
||||
using System;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
|
||||
namespace LiveCharts.Uwp.Points
|
||||
{
|
||||
//special thanks to Colin Eberhardt for the article.
|
||||
//http://www.codeproject.com/Articles/28098/A-WPF-Pie-Chart-with-Data-Binding-Support
|
||||
//http://domysee.com/blogposts/Blogpost%207%20-%20Creating%20custom%20Shapes%20for%20UWP%20Apps/
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <seealso cref="Windows.UI.Xaml.Shapes.Path" />
|
||||
[Bindable]
|
||||
public class PieSlice : Path
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PieSlice"/> class.
|
||||
/// </summary>
|
||||
public PieSlice()
|
||||
{
|
||||
RegisterPropertyChangedCallback(WidthProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(RadiusProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(PushOutProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(InnerRadiusProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(WedgeAngleProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(RotationAngleProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(XOffsetProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(YOffsetProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(PieceValueProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(HeightProperty, RenderAffectingPropertyChanged);
|
||||
RegisterPropertyChangedCallback(WidthProperty, RenderAffectingPropertyChanged);
|
||||
}
|
||||
|
||||
#region dependency properties
|
||||
|
||||
/// <summary>
|
||||
/// The radius property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty RadiusProperty =
|
||||
DependencyProperty.Register(nameof(Radius), typeof(double), typeof(PieSlice),
|
||||
new PropertyMetadata(0.0));
|
||||
//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(nameof(PushOut), typeof(double), typeof(PieSlice),
|
||||
new PropertyMetadata(0.0));
|
||||
//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(nameof(InnerRadius), typeof(double), typeof(PieSlice),
|
||||
new PropertyMetadata(0.0));
|
||||
//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(nameof(WedgeAngle), typeof(double), typeof(PieSlice),
|
||||
new PropertyMetadata(0.0));
|
||||
//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(nameof(RotationAngle), typeof(double), typeof(PieSlice),
|
||||
new PropertyMetadata(0.0));
|
||||
//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 x offset property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty XOffsetProperty =
|
||||
DependencyProperty.Register(nameof(XOffset), typeof(double), typeof(PieSlice),
|
||||
new PropertyMetadata(0.0));
|
||||
//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 XOffset
|
||||
{
|
||||
get { return (double)GetValue(XOffsetProperty); }
|
||||
set { SetValue(XOffsetProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The y offset property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty YOffsetProperty =
|
||||
DependencyProperty.Register(nameof(YOffset), typeof(double), typeof(PieSlice),
|
||||
new PropertyMetadata(0.0));
|
||||
//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 YOffset
|
||||
{
|
||||
get { return (double)GetValue(YOffsetProperty); }
|
||||
set { SetValue(YOffsetProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The percentage property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PercentageProperty =
|
||||
DependencyProperty.Register(nameof(Percentage), typeof(double), typeof(PieSlice),
|
||||
new PropertyMetadata(0.0));
|
||||
//new FrameworkPropertyMetadata(0.0));
|
||||
|
||||
/// <summary>
|
||||
/// The percentage of a full pie that this piece occupies.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The percentage.
|
||||
/// </value>
|
||||
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(nameof(PieceValue), typeof(double), typeof(PieSlice),
|
||||
new PropertyMetadata(0.0));
|
||||
// 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
|
||||
|
||||
private static void RenderAffectingPropertyChanged(DependencyObject obj, DependencyProperty dp)
|
||||
{
|
||||
(obj as PieSlice)?.SetRenderData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the pie piece
|
||||
/// </summary>
|
||||
private void SetRenderData()
|
||||
{
|
||||
var innerArcStartPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle, InnerRadius, this);
|
||||
innerArcStartPoint.X += XOffset;
|
||||
innerArcStartPoint.Y += YOffset;
|
||||
var innerArcEndPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius, this);
|
||||
innerArcEndPoint.X += XOffset;
|
||||
innerArcEndPoint.Y += YOffset;
|
||||
var outerArcStartPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle, Radius, this);
|
||||
outerArcStartPoint.X += XOffset;
|
||||
outerArcStartPoint.Y += YOffset;
|
||||
var outerArcEndPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius, this);
|
||||
outerArcEndPoint.X += XOffset;
|
||||
outerArcEndPoint.Y += YOffset;
|
||||
var innerArcMidPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle * .5, InnerRadius, this);
|
||||
innerArcMidPoint.X += XOffset;
|
||||
innerArcMidPoint.Y += YOffset;
|
||||
var outerArcMidPoint = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle * .5, Radius, this);
|
||||
outerArcMidPoint.X += XOffset;
|
||||
outerArcMidPoint.Y += YOffset;
|
||||
|
||||
var largeArc = WedgeAngle > 180.0d;
|
||||
var requiresMidPoint = Math.Abs(WedgeAngle - 360) < .01;
|
||||
|
||||
if (PushOut > 0 && !requiresMidPoint)
|
||||
{
|
||||
var offset = PieUtils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle / 2, PushOut, this);
|
||||
offset.X -= Width*.5;
|
||||
offset.Y -= Height*.5;
|
||||
innerArcStartPoint.X += offset.X;
|
||||
innerArcStartPoint.Y += offset.Y;
|
||||
innerArcEndPoint.X += offset.X;
|
||||
innerArcEndPoint.Y += offset.Y;
|
||||
outerArcStartPoint.X += offset.X;
|
||||
outerArcStartPoint.Y += offset.Y;
|
||||
outerArcEndPoint.X += offset.X;
|
||||
outerArcEndPoint.Y += offset.Y;
|
||||
}
|
||||
|
||||
var outerArcSize = new Size(Radius, Radius);
|
||||
var innerArcSize = new Size(InnerRadius, InnerRadius);
|
||||
|
||||
var pathFigure = new PathFigure { IsClosed = true, IsFilled = true, StartPoint = innerArcStartPoint };
|
||||
|
||||
if (requiresMidPoint)
|
||||
{
|
||||
pathFigure.Segments.Add(new LineSegment { Point = outerArcStartPoint });
|
||||
pathFigure.Segments.Add(new ArcSegment { Point = outerArcMidPoint, Size = outerArcSize, RotationAngle = 0, IsLargeArc = false, SweepDirection = SweepDirection.Clockwise });
|
||||
pathFigure.Segments.Add(new ArcSegment { Point = outerArcEndPoint, Size = outerArcSize, RotationAngle = 0, IsLargeArc = false, SweepDirection = SweepDirection.Clockwise });
|
||||
pathFigure.Segments.Add(new LineSegment { Point = innerArcEndPoint });
|
||||
pathFigure.Segments.Add(new ArcSegment { Point = innerArcMidPoint, Size = innerArcSize, RotationAngle = 0, IsLargeArc = false, SweepDirection = SweepDirection.Counterclockwise });
|
||||
pathFigure.Segments.Add(new ArcSegment { Point = innerArcStartPoint, Size = innerArcSize, RotationAngle = 0, IsLargeArc = false, SweepDirection = SweepDirection.Counterclockwise });
|
||||
}
|
||||
else
|
||||
{
|
||||
pathFigure.Segments.Add(new LineSegment { Point = outerArcStartPoint });
|
||||
pathFigure.Segments.Add(new ArcSegment { Point = outerArcEndPoint, Size = outerArcSize, RotationAngle = 0, IsLargeArc = largeArc, SweepDirection = SweepDirection.Clockwise });
|
||||
pathFigure.Segments.Add(new LineSegment { Point = innerArcEndPoint });
|
||||
pathFigure.Segments.Add(new ArcSegment { Point = innerArcStartPoint, Size = innerArcSize, RotationAngle = 0, IsLargeArc = largeArc, SweepDirection = SweepDirection.Counterclockwise });
|
||||
}
|
||||
|
||||
Data = new PathGeometry { Figures = new PathFigureCollection() { pathFigure }, FillRule = FillRule.EvenOdd };
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <param name="container"></param>
|
||||
/// <returns></returns>
|
||||
public static Point ComputeCartesianCoordinate(double angle, double radius, Path container)
|
||||
{
|
||||
// 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 + container.Width*.5, y + container.Height*.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Others/Live-Charts-master/UwpView/Points/PointExtensions.cs
Normal file
22
Others/Live-Charts-master/UwpView/Points/PointExtensions.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Windows.Foundation;
|
||||
|
||||
namespace LiveCharts.Uwp.Points
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class PointExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Offsets the specified x.
|
||||
/// </summary>
|
||||
/// <param name="point">The point.</param>
|
||||
/// <param name="x">The x.</param>
|
||||
/// <param name="y">The y.</param>
|
||||
public static void Offset(this Point point, double x, double y)
|
||||
{
|
||||
point.X += x;
|
||||
point.Y += y;
|
||||
}
|
||||
}
|
||||
}
|
||||
57
Others/Live-Charts-master/UwpView/Points/PointView.cs
Normal file
57
Others/Live-Charts-master/UwpView/Points/PointView.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
//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 Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
|
||||
namespace LiveCharts.Uwp.Points
|
||||
{
|
||||
internal class PointView : IChartPointView
|
||||
{
|
||||
public Shape HoverShape { get; set; }
|
||||
public ContentControl DataLabel { get; set; }
|
||||
public bool IsNew { get; set; }
|
||||
public CoreRectangle ValidArea { get; }
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
193
Others/Live-Charts-master/UwpView/Points/RowPointView.cs
Normal file
193
Others/Live-Charts-master/UwpView/Points/RowPointView.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
//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 Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.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 {Angle = 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.CreateCanvasStoryBoardAndBegin(getX(), getY(), animSpeed);
|
||||
}
|
||||
|
||||
Rectangle.BeginDoubleAnimation("(Canvas.Top)", Data.Top, animSpeed);
|
||||
Rectangle.BeginDoubleAnimation("(Canvas.Left)", Data.Left, animSpeed);
|
||||
|
||||
Rectangle.BeginDoubleAnimation("Height", Data.Height, animSpeed);
|
||||
Rectangle.BeginDoubleAnimation("Width", 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();
|
||||
if (copy == null) return;
|
||||
|
||||
copy.Opacity -= .15;
|
||||
Rectangle.Fill = copy;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
if (Rectangle == null) return;
|
||||
if (Rectangle?.Fill != null)
|
||||
Rectangle.Fill.Opacity += .15;
|
||||
if (point.Fill != null)
|
||||
{
|
||||
Rectangle.Fill = (Brush) point.Fill;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle.Fill = ((Series) point.SeriesView).Fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
153
Others/Live-Charts-master/UwpView/Points/ScatterPointView.cs
Normal file
153
Others/Live-Charts-master/UwpView/Points/ScatterPointView.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.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.CreateCanvasStoryBoardAndBegin(cx, cy, animSpeed);
|
||||
}
|
||||
|
||||
Shape.BeginDoubleAnimation(nameof(FrameworkElement.Width), Diameter, animSpeed);
|
||||
Shape.BeginDoubleAnimation(nameof(FrameworkElement.Height), Diameter, animSpeed);
|
||||
|
||||
Shape.CreateCanvasStoryBoardAndBegin(current.ChartLocation.X - Diameter*.5,
|
||||
current.ChartLocation.Y - 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();
|
||||
if (copy == null) return;
|
||||
copy.Opacity -= .15;
|
||||
Shape.Fill = copy;
|
||||
}
|
||||
|
||||
public override void OnHoverLeave(ChartPoint point)
|
||||
{
|
||||
if (Shape?.Fill == null) return;
|
||||
Shape.Fill.Opacity += .15;
|
||||
if (point.Fill != null)
|
||||
{
|
||||
Shape.Fill = (Brush) point.Fill;
|
||||
}
|
||||
else
|
||||
{
|
||||
Shape.Fill = ((Series) point.SeriesView).Fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
181
Others/Live-Charts-master/UwpView/Points/StepLinePointView.cs
Normal file
181
Others/Live-Charts-master/UwpView/Points/StepLinePointView.cs
Normal file
@@ -0,0 +1,181 @@
|
||||
//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 Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.Points
|
||||
{
|
||||
internal class StepLinePointView : PointView, IStepPointView
|
||||
{
|
||||
public double DeltaX { get; set; }
|
||||
public double DeltaY { get; set; }
|
||||
public Line VerticalLine { get; set; }
|
||||
public Line HorizontalLine { get; set; }
|
||||
public Path Shape { get; set; }
|
||||
|
||||
public override void DrawOrMove(ChartPoint previousDrawn, ChartPoint current, int index, ChartCore chart)
|
||||
{
|
||||
if (IsNew)
|
||||
{
|
||||
VerticalLine.X1 = current.ChartLocation.X;
|
||||
VerticalLine.X2 = current.ChartLocation.X;
|
||||
VerticalLine.Y1 = chart.DrawMargin.Height;
|
||||
VerticalLine.Y2 = chart.DrawMargin.Height;
|
||||
|
||||
HorizontalLine.X1 = current.ChartLocation.X - DeltaX;
|
||||
HorizontalLine.X2 = current.ChartLocation.X;
|
||||
HorizontalLine.Y1 = chart.DrawMargin.Height;
|
||||
HorizontalLine.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)
|
||||
{
|
||||
VerticalLine.X1 = current.ChartLocation.X;
|
||||
VerticalLine.X2 = current.ChartLocation.X;
|
||||
VerticalLine.Y1 = current.ChartLocation.Y;
|
||||
VerticalLine.Y2 = current.ChartLocation.Y - DeltaY;
|
||||
|
||||
HorizontalLine.X1 = current.ChartLocation.X - DeltaX;
|
||||
HorizontalLine.X2 = current.ChartLocation.X;
|
||||
HorizontalLine.Y1 = current.ChartLocation.Y - DeltaY;
|
||||
HorizontalLine.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;
|
||||
|
||||
VerticalLine.BeginDoubleAnimation(nameof(Line.X1), current.ChartLocation.X, animSpeed);
|
||||
VerticalLine.BeginDoubleAnimation(nameof(Line.X2), current.ChartLocation.X, animSpeed);
|
||||
VerticalLine.BeginDoubleAnimation(nameof(Line.Y1), current.ChartLocation.Y, animSpeed);
|
||||
VerticalLine.BeginDoubleAnimation(nameof(Line.Y2), current.ChartLocation.Y - DeltaY, animSpeed);
|
||||
|
||||
HorizontalLine.BeginDoubleAnimation(nameof(Line.X1), current.ChartLocation.X - DeltaX, animSpeed);
|
||||
HorizontalLine.BeginDoubleAnimation(nameof(Line.X2), current.ChartLocation.X, animSpeed);
|
||||
HorizontalLine.BeginDoubleAnimation(nameof(Line.Y1), current.ChartLocation.Y - DeltaY, animSpeed);
|
||||
HorizontalLine.BeginDoubleAnimation(nameof(Line.Y2), current.ChartLocation.Y - DeltaY, animSpeed);
|
||||
|
||||
Shape?.CreateCanvasStoryBoardAndBegin(current.ChartLocation.X - Shape.Width/2,
|
||||
current.ChartLocation.Y - Shape.Height/2, animSpeed);
|
||||
|
||||
if (DataLabel == null) return;
|
||||
|
||||
{
|
||||
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(VerticalLine);
|
||||
chart.View.RemoveFromDrawMargin(HorizontalLine);
|
||||
}
|
||||
|
||||
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.PointForeround
|
||||
: (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?.ActualHeight * .5 ?? 0) + 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,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 Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
using LiveCharts.Charts;
|
||||
using Windows.Foundation;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp.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);
|
||||
|
||||
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
|
||||
{
|
||||
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 (DataLabel != null)
|
||||
{
|
||||
Canvas.SetTop(DataLabel, current.ChartLocation.Y - DataLabel.ActualHeight * .5);
|
||||
Canvas.SetLeft(DataLabel, 0);
|
||||
}
|
||||
|
||||
if (Shape != null)
|
||||
{
|
||||
Canvas.SetTop(Shape, current.ChartLocation.Y - Shape.Height * .5);
|
||||
Canvas.SetLeft(Shape, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
var animSpeed = chart.View.AnimationsSpeed;
|
||||
|
||||
Segment.BeginPointAnimation(nameof(BezierSegment.Point1), Data.Point1.AsPoint(), animSpeed);
|
||||
Segment.BeginPointAnimation(nameof(BezierSegment.Point2), Data.Point2.AsPoint(), animSpeed);
|
||||
Segment.BeginPointAnimation(nameof(BezierSegment.Point3), Data.Point3.AsPoint(), animSpeed);
|
||||
|
||||
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
|
||||
{
|
||||
var storyBoard = new Storyboard();
|
||||
var xAnimation = new DoubleAnimation()
|
||||
{
|
||||
To = current.ChartLocation.X - Shape.Width * .5,
|
||||
Duration = chart.View.AnimationsSpeed
|
||||
};
|
||||
var yAnimation = new DoubleAnimation()
|
||||
{
|
||||
To = current.ChartLocation.Y - Shape.Height * .5,
|
||||
Duration = chart.View.AnimationsSpeed
|
||||
};
|
||||
Storyboard.SetTarget(xAnimation, Shape);
|
||||
Storyboard.SetTarget(yAnimation, Shape);
|
||||
Storyboard.SetTargetProperty(xAnimation, "(Canvas.Left)");
|
||||
Storyboard.SetTargetProperty(yAnimation, "(Canvas.Top)");
|
||||
storyBoard.Children.Add(xAnimation);
|
||||
storyBoard.Children.Add(yAnimation);
|
||||
storyBoard.Begin();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
var storyBoard = new Storyboard();
|
||||
|
||||
var xAnimation = new DoubleAnimation()
|
||||
{
|
||||
To = xl,
|
||||
Duration = chart.View.AnimationsSpeed
|
||||
};
|
||||
var yAnimation = new DoubleAnimation()
|
||||
{
|
||||
To = yl,
|
||||
Duration = chart.View.AnimationsSpeed
|
||||
};
|
||||
|
||||
Storyboard.SetTarget(xAnimation, DataLabel);
|
||||
Storyboard.SetTarget(yAnimation, DataLabel);
|
||||
|
||||
Storyboard.SetTargetProperty(xAnimation, "(Canvas.Left)");
|
||||
Storyboard.SetTargetProperty(yAnimation, "(Canvas.Top)");
|
||||
|
||||
storyBoard.Children.Add(xAnimation);
|
||||
storyBoard.Children.Add(yAnimation);
|
||||
|
||||
storyBoard.Begin();
|
||||
}
|
||||
|
||||
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.PointForeround
|
||||
: (Brush) point.Fill;
|
||||
lineSeries.Path.StrokeThickness = lineSeries.StrokeThickness;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Others/Live-Charts-master/UwpView/Properties/AssemblyInfo.cs
Normal file
29
Others/Live-Charts-master/UwpView/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 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("UwpView")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UwpView")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 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.3")]
|
||||
[assembly: AssemblyFileVersion("0.9.3")]
|
||||
[assembly: ComVisible(false)]
|
||||
229
Others/Live-Charts-master/UwpView/RowSeries.cs
Normal file
229
Others/Live-Charts-master/UwpView/RowSeries.cs
Normal file
@@ -0,0 +1,229 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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 label position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelPositionProperty = DependencyProperty.Register(
|
||||
"LabelPosition", typeof(BarLabelPosition), typeof(RowSeries),
|
||||
new PropertyMetadata(BarLabelPosition.Top, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets where the label is placed
|
||||
/// </summary>
|
||||
public BarLabelPosition LabelPosition
|
||||
{
|
||||
get { return (BarLabelPosition)GetValue(LabelPositionProperty); }
|
||||
set { SetValue(LabelPositionProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The shares position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SharesPositionProperty = DependencyProperty.Register(
|
||||
"SharesPosition", typeof(bool), typeof(RowSeries), new PropertyMetadata(true));
|
||||
/// <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 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.Stroke = Stroke;
|
||||
pbv.Rectangle.StrokeThickness = StrokeThickness;
|
||||
pbv.Rectangle.StrokeDashArray = StrokeDashArray;
|
||||
pbv.Rectangle.Visibility = Visibility;
|
||||
Canvas.SetZIndex(pbv.Rectangle, Canvas.GetZIndex(this));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = new SolidColorBrush(Windows.UI.Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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 = LabelPosition;
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 0d);
|
||||
|
||||
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);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
210
Others/Live-Charts-master/UwpView/ScatterSeries.cs
Normal file
210
Others/Live-Charts-master/UwpView/ScatterSeries.cs
Normal file
@@ -0,0 +1,210 @@
|
||||
//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 Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using Windows.UI.Xaml;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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(15d, 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(10d, 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 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.Parse();
|
||||
p.Fill = Fill;
|
||||
p.Stroke = Stroke;
|
||||
p.StrokeThickness = StrokeThickness;
|
||||
p.Visibility = Visibility;
|
||||
Canvas.SetZIndex(p, Canvas.GetZIndex(this));
|
||||
p.StrokeDashArray = StrokeDashArray;
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = new SolidColorBrush(Windows.UI.Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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 Public Methods
|
||||
/// <summary>
|
||||
/// Gets the point diameter.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public double GetPointDiameter()
|
||||
{
|
||||
return MaxPointShapeDiameter / 2;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 0d);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentXAxis.GetFormatter()(x.X) + ", "
|
||||
+ Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.7;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
51
Others/Live-Charts-master/UwpView/SectionsCollection.cs
Normal file
51
Others/Live-Charts-master/UwpView/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.Uwp
|
||||
{
|
||||
/// <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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
178
Others/Live-Charts-master/UwpView/Separator.cs
Normal file
178
Others/Live-Charts-master/UwpView/Separator.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
//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 Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an Axis.Separator, this class customizes the separator of an axis.
|
||||
/// </summary>
|
||||
public class Separator : Control, ISeparatorView
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of Separator class
|
||||
/// </summary>
|
||||
public Separator()
|
||||
{
|
||||
//this.SetIfNotSet(IsEnabledProperty, true);
|
||||
}
|
||||
|
||||
/// <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(new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)), 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(1d, 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);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
590
Others/Live-Charts-master/UwpView/Series.cs
Normal file
590
Others/Live-Charts-master/UwpView/Series.cs
Normal file
@@ -0,0 +1,590 @@
|
||||
//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 Windows.UI;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Text;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using LiveCharts.Defaults;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.Helpers;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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;
|
||||
RegisterPropertyChangedCallback(VisibilityProperty, OnIsVisibleChanged);
|
||||
}
|
||||
|
||||
/// <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");
|
||||
RegisterPropertyChangedCallback(VisibilityProperty, OnIsVisibleChanged);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
private IChartValues LastKnownValues { get; set; }
|
||||
internal double DefaultFillOpacity { get; 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 (Windows.ApplicationModel.DesignMode.DesignModeEnabled && (Values == null || Values.Count == 0))
|
||||
SetValue(ValuesProperty, GetValuesForDesigner());
|
||||
|
||||
return Values ?? new ChartValues<double>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the series is visible
|
||||
/// </summary>
|
||||
public bool IsSeriesVisible => Visibility == Visibility.Visible;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current chart points in the series
|
||||
/// </summary>
|
||||
public IEnumerable<ChartPoint> ChartPoints => 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
|
||||
{
|
||||
//ToDo: fix binding series threading issue..
|
||||
return (IChartValues) GetValue(ValuesProperty);
|
||||
}
|
||||
set { SetValue(ValuesProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The title property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
|
||||
"Title", typeof (string), typeof (Series),
|
||||
new PropertyMetadata("Series", CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets series title
|
||||
/// </summary>
|
||||
public string Title
|
||||
{
|
||||
get { return (string) GetValue(TitleProperty); }
|
||||
set { SetValue(TitleProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsFirstDraw { get; }
|
||||
|
||||
/// <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(2d, 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(default(FontFamily)));
|
||||
/// <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(FontStyle.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(FontStretch.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.FromArgb(255, 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 (PointGeometry), 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 PointGeometry PointGeometry
|
||||
{
|
||||
get { return (PointGeometry) 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(nameof(Visibility)), Source = this });
|
||||
Canvas.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 =>
|
||||
{
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the series colors if they are not set
|
||||
/// </summary>
|
||||
public virtual void InitializeColors()
|
||||
{
|
||||
var uwpfChart = (Chart) Model.Chart.View;
|
||||
if (Stroke != null && Fill != null) return;
|
||||
|
||||
var nextColor = uwpfChart.GetNextDefaultColor();
|
||||
|
||||
if (Stroke == null)
|
||||
{
|
||||
var strokeBrush = new SolidColorBrush(nextColor);
|
||||
// Todo: Find out what is going on with freezables... also freeze Fill if possible...
|
||||
// strokeBrush.Freeze(); ???
|
||||
SetValue(StrokeProperty, strokeBrush);
|
||||
}
|
||||
if (Fill == null)
|
||||
SetValue(FillProperty, new SolidColorBrush(nextColor) {Opacity = DefaultFillOpacity});
|
||||
}
|
||||
|
||||
/// <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 (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
|
||||
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?.GetPoints(series).ForEach(
|
||||
x =>
|
||||
{
|
||||
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?.Model == null) return;
|
||||
|
||||
wpfSeries.Model.Chart?.Updater.Run(animate);
|
||||
};
|
||||
}
|
||||
|
||||
private Visibility? PreviousVisibility { get; set; }
|
||||
|
||||
private void OnIsVisibleChanged(DependencyObject sender, DependencyProperty e)
|
||||
{
|
||||
if (Model.Chart == null || PreviousVisibility == Visibility) return;
|
||||
|
||||
PreviousVisibility = Visibility;
|
||||
|
||||
if (PreviousVisibility != null) Model.Chart.Updater.Run();
|
||||
|
||||
if (Visibility == Visibility.Collapsed || Visibility == Visibility.Collapsed)
|
||||
{
|
||||
Erase(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static IChartValues GetValuesForDesigner()
|
||||
{
|
||||
var r = new Random();
|
||||
var gvt = Type.GetType("LiveCharts.Geared.GearedValues`1, LiveCharts.Geared");
|
||||
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
|
||||
}
|
||||
}
|
||||
173
Others/Live-Charts-master/UwpView/StackedAreaSeries.cs
Normal file
173
Others/Live-Charts-master/UwpView/StackedAreaSeries.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 Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
/// The stacked area compares trends and percentage, add this series to a cartesian chart
|
||||
/// </summary>
|
||||
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 == short.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.BeginPointAnimation(nameof(PathFigure.StartPoint), 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);
|
||||
Canvas.SetZIndex(Path, Model.Chart.View.Series.Count - i);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{;
|
||||
//this.SetIfNotSet(PointGeometrySizeProperty, 0d);
|
||||
//this.SetIfNotSet(ForegroundProperty, new SolidColorBrush(Color.FromArgb(255, 229, 229, 229)));
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 0d);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
Splitters = new List<LineSegmentSplitter>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
217
Others/Live-Charts-master/UwpView/StackedColumnSeries.cs
Normal file
217
Others/Live-Charts-master/UwpView/StackedColumnSeries.cs
Normal file
@@ -0,0 +1,217 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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(35d));
|
||||
/// <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(2d));
|
||||
/// <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;
|
||||
Canvas.SetZIndex(pbv.Rectangle, Canvas.GetZIndex(this));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = new SolidColorBrush(Windows.UI.Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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()
|
||||
{
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 0d);
|
||||
//this.SetIfNotSet(ForegroundProperty, new SolidColorBrush(Windows.UI.Colors.White));
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
222
Others/Live-Charts-master/UwpView/StackedRowSeries.cs
Normal file
222
Others/Live-Charts-master/UwpView/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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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(35d));
|
||||
/// <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(2d));
|
||||
/// <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 label position property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty LabelPositionProperty = DependencyProperty.Register(
|
||||
"LabelPosition", typeof(BarLabelPosition), typeof(StackedRowSeries),
|
||||
new PropertyMetadata(BarLabelPosition.Parallel, CallChartUpdater()));
|
||||
/// <summary>
|
||||
/// Gets or sets where the label is placed
|
||||
/// </summary>
|
||||
public BarLabelPosition LabelPosition
|
||||
{
|
||||
get { return (BarLabelPosition)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 = (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;
|
||||
Canvas.SetZIndex(pbv.Rectangle, Canvas.GetZIndex(this));
|
||||
|
||||
if (Model.Chart.RequiresHoverShape && pbv.HoverShape == null)
|
||||
{
|
||||
pbv.HoverShape = new Rectangle
|
||||
{
|
||||
Fill = new SolidColorBrush(Windows.UI.Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.DataLabel);
|
||||
}
|
||||
|
||||
pbv.LabelPosition = LabelPosition;
|
||||
|
||||
return pbv;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 0d);
|
||||
//this.SetIfNotSet(ForegroundProperty, new SolidColorBrush(Windows.UI.Colors.White));
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentXAxis.GetFormatter()(x.X);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
274
Others/Live-Charts-master/UwpView/StepLineSeries.cs
Normal file
274
Others/Live-Charts-master/UwpView/StepLineSeries.cs
Normal file
@@ -0,0 +1,274 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Components;
|
||||
using LiveCharts.Uwp.Points;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <summary>
|
||||
/// ThesStep line series
|
||||
/// </summary>
|
||||
/// <seealso cref="LiveCharts.Uwp.Series" />
|
||||
/// <seealso cref="LiveCharts.Uwp.Components.IFondeable" />
|
||||
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 PointForeroundProperty = DependencyProperty.Register(
|
||||
"PointForeround", typeof(Brush), typeof(StepLineSeries),
|
||||
new PropertyMetadata(default(Brush)));
|
||||
/// <summary>
|
||||
/// Gets or sets the point shape foreground.
|
||||
/// </summary>
|
||||
public Brush PointForeround
|
||||
{
|
||||
get { return (Brush)GetValue(PointForeroundProperty); }
|
||||
set { SetValue(PointForeroundProperty, 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); }
|
||||
}
|
||||
|
||||
#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,
|
||||
HorizontalLine = new Line(),
|
||||
VerticalLine = new Line()
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HorizontalLine);
|
||||
Model.Chart.View.AddToDrawMargin(pbv.VerticalLine);
|
||||
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.HorizontalLine);
|
||||
point.SeriesView.Model.Chart.View
|
||||
.EnsureElementBelongsToCurrentDrawMargin(pbv.VerticalLine);
|
||||
}
|
||||
|
||||
pbv.VerticalLine.StrokeThickness = StrokeThickness;
|
||||
pbv.VerticalLine.Stroke = AlternativeStroke;
|
||||
pbv.VerticalLine.StrokeDashArray = StrokeDashArray;
|
||||
pbv.VerticalLine.Visibility = Visibility;
|
||||
Canvas.SetZIndex(pbv.VerticalLine, Canvas.GetZIndex(this));
|
||||
|
||||
pbv.HorizontalLine.StrokeThickness = StrokeThickness;
|
||||
pbv.HorizontalLine.Stroke = Stroke;
|
||||
pbv.HorizontalLine.StrokeDashArray = StrokeDashArray;
|
||||
pbv.HorizontalLine.Visibility = Visibility;
|
||||
Canvas.SetZIndex(pbv.HorizontalLine, Canvas.GetZIndex(this));
|
||||
|
||||
if (Math.Abs(PointGeometrySize) > 0.1 && pbv.Shape == null)
|
||||
{
|
||||
pbv.Shape = new Path
|
||||
{
|
||||
Stretch = Stretch.Fill,
|
||||
StrokeThickness = StrokeThickness
|
||||
};
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Shape);
|
||||
}
|
||||
|
||||
if (pbv.Shape != null)
|
||||
{
|
||||
pbv.Shape.Fill = PointForeround;
|
||||
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.Parse();
|
||||
Canvas.SetZIndex(pbv.Shape, Canvas.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 = new SolidColorBrush(Windows.UI.Colors.Transparent),
|
||||
StrokeThickness = 0
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.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 uwpfChart = (Chart)Model.Chart.View;
|
||||
|
||||
if (Stroke != null && AlternativeStroke != null) return;
|
||||
|
||||
var nextColor = uwpfChart.GetNextDefaultColor();
|
||||
|
||||
if (Stroke == null)
|
||||
SetValue(StrokeProperty, new SolidColorBrush(nextColor));
|
||||
if (AlternativeStroke == null)
|
||||
SetValue(AlternativeStrokeProperty, new SolidColorBrush(nextColor));
|
||||
if (Fill == null)
|
||||
SetValue(FillProperty, new SolidColorBrush(nextColor) { Opacity = DefaultFillOpacity });
|
||||
}
|
||||
|
||||
#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()
|
||||
{
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentYAxis.GetFormatter()(x.Y);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.15;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
13
Others/Live-Charts-master/UwpView/Themes/Colors/black.xaml
Normal file
13
Others/Live-Charts-master/UwpView/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.Uwp">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color>#FF0F0F0F</Color>
|
||||
<Color>#FF212121</Color>
|
||||
<Color>#FF303030</Color>
|
||||
<Color>#FF424242</Color>
|
||||
<Color>#FF545454</Color>
|
||||
</lvc:ColorsCollection>
|
||||
|
||||
</ResourceDictionary>
|
||||
13
Others/Live-Charts-master/UwpView/Themes/Colors/blue.xaml
Normal file
13
Others/Live-Charts-master/UwpView/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.Uwp">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color>#FF0D47A1</Color>
|
||||
<Color>#FF1976D2</Color>
|
||||
<Color>#FF2196F3</Color>
|
||||
<Color>#FF64B5F6</Color>
|
||||
<Color>#FFBBDEFB</Color>
|
||||
</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.Uwp">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color>#FF2195F2</Color>
|
||||
<Color>#FFF34336</Color>
|
||||
<Color>#FFFEC007</Color>
|
||||
<Color>#FF607D8A</Color>
|
||||
<Color>#FFE81E63</Color>
|
||||
<Color>#FF4CAE50</Color>
|
||||
<Color>#FF3F51B4</Color>
|
||||
<Color>#FFCCDB39</Color>
|
||||
</lvc:ColorsCollection>
|
||||
|
||||
</ResourceDictionary>
|
||||
16
Others/Live-Charts-master/UwpView/Themes/Colors/metro.xaml
Normal file
16
Others/Live-Charts-master/UwpView/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.Uwp">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color>#FF2D89EF</Color>
|
||||
<Color>#FFEE1111</Color>
|
||||
<Color>#FFFFC40D</Color>
|
||||
<Color>#FF00ABA9</Color>
|
||||
<Color>#FFFF0097</Color>
|
||||
<Color>#FF00A300</Color>
|
||||
<Color>#FFDA532C</Color>
|
||||
<Color>#FF2B5797</Color>
|
||||
</lvc:ColorsCollection>
|
||||
|
||||
</ResourceDictionary>
|
||||
13
Others/Live-Charts-master/UwpView/Themes/Colors/white.xaml
Normal file
13
Others/Live-Charts-master/UwpView/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.Uwp">
|
||||
|
||||
<lvc:ColorsCollection x:Key="ColorsCollection">
|
||||
<Color>#FFFFFFFF</Color>
|
||||
<Color>#FFFAFAFA</Color>
|
||||
<Color>#FFF5F5F5</Color>
|
||||
<Color>#FFF0F0F0</Color>
|
||||
<Color>#FFEBEBEB</Color>
|
||||
</lvc:ColorsCollection>
|
||||
|
||||
</ResourceDictionary>
|
||||
7
Others/Live-Charts-master/UwpView/Themes/Size/l.xaml
Normal file
7
Others/Live-Charts-master/UwpView/Themes/Size/l.xaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="using:System">
|
||||
|
||||
<system:Double x:Key="Size">15</system:Double>
|
||||
|
||||
</ResourceDictionary>
|
||||
7
Others/Live-Charts-master/UwpView/Themes/Size/m.xaml
Normal file
7
Others/Live-Charts-master/UwpView/Themes/Size/m.xaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="using:System">
|
||||
|
||||
<system:Double x:Key="Size">12</system:Double>
|
||||
|
||||
</ResourceDictionary>
|
||||
7
Others/Live-Charts-master/UwpView/Themes/Size/s.xaml
Normal file
7
Others/Live-Charts-master/UwpView/Themes/Size/s.xaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="using:System">
|
||||
|
||||
<system:Double x:Key="Size">10</system:Double>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="using:System">
|
||||
|
||||
<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>
|
||||
@@ -0,0 +1,9 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="using:System">
|
||||
|
||||
<system:Double x:Key="SeparatorStrokeThickness">1.3</system:Double>
|
||||
<DoubleCollection x:Key="SeparatorStrokeDashArray"></DoubleCollection>
|
||||
<system:Double x:Key="SeriesStrokeThickness">1</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:system="using:System">
|
||||
|
||||
<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>
|
||||
61
Others/Live-Charts-master/UwpView/Themes/base.xaml
Normal file
61
Others/Live-Charts-master/UwpView/Themes/base.xaml
Normal file
@@ -0,0 +1,61 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Uwp" >
|
||||
|
||||
<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>
|
||||
<!--<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="lvc:Separator" x:Name="Separator">
|
||||
<lvc:Separator>
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<core:DataTriggerBehavior Binding="{TemplateBinding AxisOrientation}" Value="X">
|
||||
<core:ChangePropertyAction PropertyName="IsEnabled" Value="False"></core:ChangePropertyAction>
|
||||
</core:DataTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</lvc:Separator>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>-->
|
||||
</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}"/>
|
||||
|
||||
</ResourceDictionary>
|
||||
371
Others/Live-Charts-master/UwpView/UwpView.csproj
Normal file
371
Others/Live-Charts-master/UwpView/UwpView.csproj
Normal file
@@ -0,0 +1,371 @@
|
||||
<?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>{9F22A3E2-CE88-41C3-8117-E9D3901BAA48}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LiveCharts.Uwp</RootNamespace>
|
||||
<AssemblyName>LiveCharts.Uwp</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<RuntimeIdentifiers>win10-arm;win10-arm-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot</RuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateLibraryLayout>true</GenerateLibraryLayout>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<GenerateLibraryLayout>true</GenerateLibraryLayout>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<GenerateLibraryLayout>true</GenerateLibraryLayout>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<GenerateLibraryLayout>true</GenerateLibraryLayout>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<GenerateLibraryLayout>true</GenerateLibraryLayout>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
|
||||
<None Include="key.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AngularGauge.cs" />
|
||||
<Compile Include="AngularSection.cs" />
|
||||
<Compile Include="AxesCollection.cs" />
|
||||
<Compile Include="Axis.cs" />
|
||||
<Compile Include="AxisSection.cs" />
|
||||
<Compile Include="CandleSeries.cs" />
|
||||
<Compile Include="CartesianChart.cs" />
|
||||
<Compile Include="Charts\Base\Chart.cs" />
|
||||
<Compile Include="ColorsCollection.cs" />
|
||||
<Compile Include="ColumnSeries.cs" />
|
||||
<Compile Include="Components\AnimationsHelper.cs" />
|
||||
<Compile Include="Components\AxisSeparatorElement.cs" />
|
||||
<Compile Include="Components\BrushCloner.cs" />
|
||||
<Compile Include="Components\ChartUpdater.cs" />
|
||||
<Compile Include="Components\Converters.cs" />
|
||||
<Compile Include="Components\DefaultXamlReader.cs" />
|
||||
<Compile Include="Components\DependencyObjectExtensions.cs" />
|
||||
<Compile Include="Components\GeometryHelper.cs" />
|
||||
<Compile Include="Components\GeometryParser.cs" />
|
||||
<Compile Include="Components\IFondeable.cs" />
|
||||
<Compile Include="Components\MultiBinding\DependencyObjectCollection.cs" />
|
||||
<Compile Include="Components\MultiBinding\MultiBindingBehavior.cs" />
|
||||
<Compile Include="Components\MultiBinding\MultiBindingItem.cs" />
|
||||
<Compile Include="Components\MultiBinding\MultiBindingItemCollection.cs" />
|
||||
<Compile Include="Components\MultiBinding\MultiValueConverterBase.cs" />
|
||||
<Compile Include="Components\TooltipDto.cs" />
|
||||
<Compile Include="Converters\StringFormatConverter.cs" />
|
||||
<Compile Include="Converters\TypeConverters.cs" />
|
||||
<Compile Include="DefaultAxes.cs" />
|
||||
<Compile Include="DefaultGeoMapTooltip.xaml.cs">
|
||||
<DependentUpon>DefaultGeoMapTooltip.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DefaultGeometry.cs" />
|
||||
<Compile Include="DefaultLegend.xaml.cs">
|
||||
<DependentUpon>DefaultLegend.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DefaultTooltip.xaml.cs">
|
||||
<DependentUpon>DefaultTooltip.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Extentions.cs" />
|
||||
<Compile Include="Gauge.cs" />
|
||||
<Compile Include="GeoMap.cs" />
|
||||
<Compile Include="HeatColorRange.xaml.cs">
|
||||
<DependentUpon>HeatColorRange.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="HeatSeries.cs" />
|
||||
<Compile Include="IChartLegend.cs" />
|
||||
<Compile Include="IChartTooltip.cs" />
|
||||
<Compile Include="LineSegmentSplitter.cs" />
|
||||
<Compile Include="LineSeries.cs" />
|
||||
<Compile Include="LogarithmicAxis.cs" />
|
||||
<Compile Include="Maps\MapResolver.cs" />
|
||||
<Compile Include="OhlcSeries.cs" />
|
||||
<Compile Include="PieChart.cs" />
|
||||
<Compile Include="PieSeries.cs" />
|
||||
<Compile Include="PointGeometry.cs" />
|
||||
<Compile Include="Points\CandlePointView.cs" />
|
||||
<Compile Include="Points\ColumnPointView.cs" />
|
||||
<Compile Include="Points\HeatPoint.cs" />
|
||||
<Compile Include="Points\HorizontalBezierPointView.cs" />
|
||||
<Compile Include="Points\OhlcPointView.cs" />
|
||||
<Compile Include="Points\PiePointView.cs" />
|
||||
<Compile Include="Points\PieSlice.cs" />
|
||||
<Compile Include="Points\PointExtensions.cs" />
|
||||
<Compile Include="Points\PointView.cs" />
|
||||
<Compile Include="Points\RowPointView.cs" />
|
||||
<Compile Include="Points\ScatterPointView.cs" />
|
||||
<Compile Include="Points\StepLinePointView.cs" />
|
||||
<Compile Include="Points\VerticalBezierPointView.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RowSeries.cs" />
|
||||
<Compile Include="ScatterSeries.cs" />
|
||||
<Compile Include="SectionsCollection.cs" />
|
||||
<Compile Include="Separator.cs" />
|
||||
<Compile Include="Series.cs" />
|
||||
<Compile Include="StackedAreaSeries.cs" />
|
||||
<Compile Include="StackedColumnSeries.cs" />
|
||||
<Compile Include="StackedRowSeries.cs" />
|
||||
<Compile Include="StepLineSeries.cs" />
|
||||
<Compile Include="VerticalLineSeries.cs" />
|
||||
<Compile Include="VerticalStackedAreaSeries.cs" />
|
||||
<Compile Include="VisualElement.cs" />
|
||||
<EmbeddedResource Include="Properties\UwpView.rd.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="DefaultGeoMapTooltip.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="DefaultLegend.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="DefaultTooltip.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="HeatColorRange.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core\Core.csproj">
|
||||
<Project>{d447642c-a85f-4ab0-96d9-c66cff91aada}</Project>
|
||||
<Name>Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>5.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
|
||||
<Version>2.0.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>key.pfx</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'r86|AnyCPU'">
|
||||
<OutputPath>bin\r86\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<GenerateLibraryLayout>true</GenerateLibraryLayout>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'r86|x86'">
|
||||
<OutputPath>bin\x86\r86\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'r86|ARM'">
|
||||
<OutputPath>bin\ARM\r86\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'r86|x64'">
|
||||
<OutputPath>bin\x64\r86\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'r64|AnyCPU'">
|
||||
<OutputPath>bin\r64\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<GenerateLibraryLayout>true</GenerateLibraryLayout>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'r64|x86'">
|
||||
<OutputPath>bin\x86\r64\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'r64|ARM'">
|
||||
<OutputPath>bin\ARM\r64\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'r64|x64'">
|
||||
<OutputPath>bin\x64\r64\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<DocumentationFile>bin\Debug\LiveCharts.Uwp.XML</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'arm|AnyCPU'">
|
||||
<OutputPath>bin\arm\</OutputPath>
|
||||
<GenerateLibraryLayout>true</GenerateLibraryLayout>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'arm|x86'">
|
||||
<OutputPath>bin\x86\arm\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'arm|ARM'">
|
||||
<OutputPath>bin\ARM\arm\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'arm|x64'">
|
||||
<OutputPath>bin\x64\arm\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.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>
|
||||
31
Others/Live-Charts-master/UwpView/UwpView.nuspec
Normal file
31
Others/Live-Charts-master/UwpView/UwpView.nuspec
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0"?>
|
||||
<package >
|
||||
<metadata>
|
||||
<id>LiveCharts.Uwp</id>
|
||||
<version>0.8.0.0</version>
|
||||
<title>LiveCharts.Uwp</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 Uwp</description>
|
||||
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
|
||||
<copyright>Copyright 2016</copyright>
|
||||
<tags>livechart, live, chart, charting, plot, plots, plotting, graph, graphs, graphing, data, uwp, universal, windows, platform</tags>
|
||||
<dependencies>
|
||||
<dependency id="LiveCharts" version="0.8.0.0" />
|
||||
<dependency id="Microsoft.Xaml.Behaviors.Uwp.Managed" version="2.0.0.0" />
|
||||
<dependency id="Microsoft.NETCore.UniversalWindowsPlatform" version="5.2.2" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="install.ps1" target="tools" />
|
||||
<file src="bin\AnyCPU\LiveCharts.Uwp.dll" target="lib\uap10.0"/>
|
||||
<file src="bin\AnyCPU\LiveCharts.Uwp.pdb" target="lib\uap10.0"/>
|
||||
<file src="bin\AnyCPU\LiveCharts.Uwp.xml" target="lib\uap10.0"/>
|
||||
<file src="bin\AnyCPU\LiveCharts.Uwp.pri" target="lib\uap10.0"/>
|
||||
<file src="bin\AnyCPU\LiveCharts.Uwp\*.*" target="lib\uap10.0\LiveCharts.Uwp"/>
|
||||
</files>
|
||||
</package>
|
||||
338
Others/Live-Charts-master/UwpView/VerticalLineSeries.cs
Normal file
338
Others/Live-Charts-master/UwpView/VerticalLineSeries.cs
Normal file
@@ -0,0 +1,338 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.Perception.Spatial;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Points;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Points;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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;
|
||||
Canvas.SetZIndex(Path, Canvas.GetZIndex(this));
|
||||
return;
|
||||
}
|
||||
|
||||
IsPathInitialized = true;
|
||||
|
||||
Path = new Path
|
||||
{
|
||||
Stroke = Stroke,
|
||||
StrokeThickness = StrokeThickness,
|
||||
Fill = Fill,
|
||||
Visibility = Visibility,
|
||||
StrokeDashArray = StrokeDashArray
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(Path, Canvas.GetZIndex(this));
|
||||
|
||||
var geometry = new PathGeometry();
|
||||
Figure = new PathFigure();
|
||||
geometry.Figures.Add(Figure);
|
||||
Path.Data = geometry;
|
||||
|
||||
Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(Path);
|
||||
}
|
||||
|
||||
/// <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 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 = new SolidColorBrush(Windows.UI.Colors.Transparent),
|
||||
StrokeThickness = 0,
|
||||
Width = mhr,
|
||||
Height = mhr
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(pbv.HoverShape, short.MaxValue);
|
||||
|
||||
var uwpfChart = (Chart)Model.Chart.View;
|
||||
uwpfChart.AttachHoverableEventTo(pbv.HoverShape);
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.HoverShape);
|
||||
}
|
||||
|
||||
if (pbv.HoverShape != null) pbv.HoverShape.Visibility = Visibility;
|
||||
|
||||
if (Math.Abs(PointGeometrySize) > 0.1 && pbv.Shape == null)
|
||||
{
|
||||
pbv.Shape = new Path
|
||||
{
|
||||
Stretch = Stretch.Fill,
|
||||
StrokeThickness = StrokeThickness
|
||||
};
|
||||
|
||||
Model.Chart.View.AddToDrawMargin(pbv.Shape);
|
||||
}
|
||||
|
||||
if (pbv.Shape != null)
|
||||
{
|
||||
pbv.Shape.Fill = PointForeround;
|
||||
pbv.Shape.Stroke = Stroke;
|
||||
pbv.Shape.StrokeThickness = StrokeThickness;
|
||||
pbv.Shape.Width = PointGeometrySize;
|
||||
pbv.Shape.Height = PointGeometrySize;
|
||||
pbv.Shape.Data = PointGeometry.Parse();
|
||||
pbv.Shape.Visibility = Visibility;
|
||||
Canvas.SetZIndex(pbv.Shape, Canvas.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.BeginPointAnimation(nameof(PathFigure.StartPoint),
|
||||
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.BeginPointAnimation(nameof(LineSegment.Point),
|
||||
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.BeginPointAnimation(nameof(LineSegment.Point),
|
||||
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.BeginPointAnimation(nameof(LineSegment.Point),
|
||||
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.BeginPointAnimation(nameof(LineSegment.Point),
|
||||
new Point(areaLimit, location.Y), animSpeed);
|
||||
Figure.Segments.Insert(atIndex, splitter.Right);
|
||||
|
||||
splitter.IsNew = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentXAxis.GetFormatter()(x.X);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 0.15;
|
||||
Splitters = new List<LineSegmentSplitter>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
171
Others/Live-Charts-master/UwpView/VerticalStackedAreaSeries.cs
Normal file
171
Others/Live-Charts-master/UwpView/VerticalStackedAreaSeries.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
//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 Windows.Foundation;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
using LiveCharts.Definitions.Series;
|
||||
using LiveCharts.SeriesAlgorithms;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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(StackMode.Values));
|
||||
/// <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 == short.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.BeginPointAnimation(nameof(PathFigure.StartPoint), 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
|
||||
};
|
||||
|
||||
Canvas.SetZIndex(Path, Canvas.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);
|
||||
Canvas.SetZIndex(Path, Model.Chart.View.Series.Count - i);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void InitializeDefuaults()
|
||||
{
|
||||
//this.SetIfNotSet(PointGeometrySizeProperty, 0d);
|
||||
//this.SetIfNotSet(ForegroundProperty, new SolidColorBrush(Color.FromArgb(255, 229, 229, 229)));
|
||||
//this.SetIfNotSet(StrokeThicknessProperty, 0d);
|
||||
|
||||
Func<ChartPoint, string> defaultLabel = x => Model.CurrentXAxis.GetFormatter()(x.X);
|
||||
this.SetIfNotSet(LabelPointProperty, defaultLabel);
|
||||
|
||||
DefaultFillOpacity = 1;
|
||||
Splitters = new List<LineSegmentSplitter>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
187
Others/Live-Charts-master/UwpView/VisualElement.cs
Normal file
187
Others/Live-Charts-master/UwpView/VisualElement.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
//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 Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using LiveCharts.Charts;
|
||||
using LiveCharts.Definitions.Charts;
|
||||
using LiveCharts.Dtos;
|
||||
using LiveCharts.Uwp.Charts.Base;
|
||||
using LiveCharts.Uwp.Components;
|
||||
|
||||
namespace LiveCharts.Uwp
|
||||
{
|
||||
/// <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?.AxisX == null || chart?.AxisY == null || UIElement == null) return;
|
||||
if (UIElement.Parent == null)
|
||||
{
|
||||
chart.View.AddToDrawMargin(UIElement);
|
||||
Canvas.SetZIndex(UIElement, 1000);
|
||||
}
|
||||
|
||||
var coordinate = new CorePoint(ChartFunctions.ToDrawMargin(X, AxisOrientation.X, chart, AxisX),
|
||||
ChartFunctions.ToDrawMargin(Y, AxisOrientation.Y, chart, AxisY));
|
||||
|
||||
var uwpChart = (CartesianChart) chart.View;
|
||||
|
||||
var uw = new CorePoint(
|
||||
uwpChart.AxisX[AxisX].Model.EvaluatesUnitWidth
|
||||
? ChartFunctions.GetUnitWidth(AxisOrientation.X, chart, AxisX)/2
|
||||
: 0,
|
||||
uwpChart.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);
|
||||
}
|
||||
|
||||
var x = AnimationsHelper.CreateDouble(coordinate.X, uwpChart.AnimationsSpeed, "(Canvas.Left)");
|
||||
var y = AnimationsHelper.CreateDouble(coordinate.Y, uwpChart.AnimationsSpeed, "(Canvas.Top)");
|
||||
AnimationsHelper.CreateStoryBoardAndBegin(UIElement, x, y);
|
||||
}
|
||||
_owner = chart;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified chart.
|
||||
/// </summary>
|
||||
/// <param name="chart">The chart.</param>
|
||||
public void Remove(ChartCore chart)
|
||||
{
|
||||
chart.View.RemoveFromView(UIElement);
|
||||
}
|
||||
|
||||
private static void PropertyChangedCallback(DependencyObject dependencyObject,
|
||||
DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||
{
|
||||
var element = (VisualElement) dependencyObject;
|
||||
if (element._owner != null) element.AddOrMove(element._owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Others/Live-Charts-master/UwpView/install.ps1
Normal file
3
Others/Live-Charts-master/UwpView/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/UwpView/nuget.exe
Normal file
BIN
Others/Live-Charts-master/UwpView/nuget.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user