// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2014 OxyPlot contributors
//
//
// This is a Avalonia wrapper of OxyPlot.LineSeries
//
// --------------------------------------------------------------------------------------------------------------------
using Avalonia;
namespace OxyPlot.Avalonia
{
using global::Avalonia.Media;
///
/// This is a wrapper of OxyPlot.PieSeries.
///
public class PieSeries : ItemsSeries
{
///
/// Identifies the dependency property.
///
public static readonly StyledProperty StrokeProperty = AvaloniaProperty.Register(nameof(Stroke), Colors.White);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty StrokeThicknessProperty = AvaloniaProperty.Register(nameof(StrokeThickness), 1.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty DiameterProperty = AvaloniaProperty.Register(nameof(Diameter), 1.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty InnerDiameterProperty = AvaloniaProperty.Register(nameof(InnerDiameter), 0.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty StartAngleProperty = AvaloniaProperty.Register(nameof(StartAngle), 0.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty AngleSpanProperty = AvaloniaProperty.Register(nameof(AngleSpan), 360.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty AngleIncrementProperty = AvaloniaProperty.Register(nameof(AngleIncrement), 1.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty LegendFormatProperty = AvaloniaProperty.Register(nameof(LegendFormat), null);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty OutsideLabelFormatProperty = AvaloniaProperty.Register(nameof(OutsideLabelFormat), "{2:0} %");
///
/// Identifies the dependency property.
///
public static readonly StyledProperty InsideLabelColorProperty = AvaloniaProperty.Register(nameof(InsideLabelColor), MoreColors.Automatic);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty InsideLabelFormatProperty = AvaloniaProperty.Register(nameof(InsideLabelFormat), "{1}");
///
/// Identifies the dependency property.
///
public static readonly StyledProperty InsideLabelPositionProperty = AvaloniaProperty.Register(nameof(InsideLabelPosition), 0.5);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty AreInsideLabelsAngledProperty = AvaloniaProperty.Register(nameof(AreInsideLabelsAngled), false);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty TickDistanceProperty = AvaloniaProperty.Register(nameof(TickDistance), 0.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty TickRadialLengthProperty = AvaloniaProperty.Register(nameof(TickRadialLength), 6.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty TickHorizontalLengthProperty = AvaloniaProperty.Register(nameof(TickHorizontalLength), 8.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty TickLabelDistanceProperty = AvaloniaProperty.Register(nameof(TickLabelDistance), 4.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty ExplodedDistanceProperty = AvaloniaProperty.Register(nameof(ExplodedDistance), 0.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty LabelFieldProperty = AvaloniaProperty.Register(nameof(LabelField), null);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty ValueFieldProperty = AvaloniaProperty.Register(nameof(ValueField), null);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty ColorFieldProperty = AvaloniaProperty.Register(nameof(ColorField), null);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty IsExplodedFieldProperty = AvaloniaProperty.Register(nameof(IsExplodedField), null);
///
/// Initializes static members of the class.
///
static PieSeries()
{
TrackerFormatStringProperty
.OverrideMetadata(
typeof(PieSeries),
new StyledPropertyMetadata(OxyPlot.Series.PieSeries.DefaultTrackerFormatString));
StrokeProperty.Changed.AddClassHandler(AppearanceChanged);
StrokeThicknessProperty.Changed.AddClassHandler(AppearanceChanged);
DiameterProperty.Changed.AddClassHandler(AppearanceChanged);
InnerDiameterProperty.Changed.AddClassHandler(AppearanceChanged);
StartAngleProperty.Changed.AddClassHandler(AppearanceChanged);
AngleSpanProperty.Changed.AddClassHandler(AppearanceChanged);
AngleIncrementProperty.Changed.AddClassHandler(AppearanceChanged);
LegendFormatProperty.Changed.AddClassHandler(AppearanceChanged);
OutsideLabelFormatProperty.Changed.AddClassHandler(AppearanceChanged);
InsideLabelColorProperty.Changed.AddClassHandler(AppearanceChanged);
InsideLabelFormatProperty.Changed.AddClassHandler(AppearanceChanged);
InsideLabelPositionProperty.Changed.AddClassHandler(AppearanceChanged);
AreInsideLabelsAngledProperty.Changed.AddClassHandler(AppearanceChanged);
TickDistanceProperty.Changed.AddClassHandler(AppearanceChanged);
TickRadialLengthProperty.Changed.AddClassHandler(AppearanceChanged);
TickHorizontalLengthProperty.Changed.AddClassHandler(AppearanceChanged);
TickLabelDistanceProperty.Changed.AddClassHandler(AppearanceChanged);
LabelFieldProperty.Changed.AddClassHandler(DataChanged);
ValueFieldProperty.Changed.AddClassHandler(DataChanged);
ColorFieldProperty.Changed.AddClassHandler(DataChanged);
IsExplodedFieldProperty.Changed.AddClassHandler(DataChanged);
TrackerFormatStringProperty.Changed.AddClassHandler(AppearanceChanged);
}
///
/// Initializes a new instance of the class.
///
public PieSeries()
{
InternalSeries = new OxyPlot.Series.PieSeries();
}
///
/// Creates the underlying model.
///
/// A series.
public override OxyPlot.Series.Series CreateModel()
{
SynchronizeProperties(InternalSeries);
return InternalSeries;
}
///
/// Gets or sets the stroke color.
///
public Color Stroke
{
get { return GetValue(StrokeProperty); }
set { SetValue(StrokeProperty, value); }
}
///
/// Gets or sets the stroke thickness.
///
public double StrokeThickness
{
get { return GetValue(StrokeThicknessProperty); }
set { SetValue(StrokeThicknessProperty, value); }
}
///
/// Gets or sets the diameter.
///
public double Diameter
{
get { return GetValue(DiameterProperty); }
set { SetValue(DiameterProperty, value); }
}
///
/// Gets or sets the inner diameter.
///
public double InnerDiameter
{
get { return GetValue(InnerDiameterProperty); }
set { SetValue(InnerDiameterProperty, value); }
}
///
/// Gets or sets the start angle.
///
public double StartAngle
{
get { return GetValue(StartAngleProperty); }
set { SetValue(StartAngleProperty, value); }
}
///
/// Gets or sets the angle span.
///
public double AngleSpan
{
get { return GetValue(AngleSpanProperty); }
set { SetValue(AngleSpanProperty, value); }
}
///
/// Gets or sets the angle increment.
///
public double AngleIncrement
{
get { return GetValue(AngleIncrementProperty); }
set { SetValue(AngleIncrementProperty, value); }
}
///
/// Gets or sets the legend format.
///
public string LegendFormat
{
get { return GetValue(LegendFormatProperty); }
set { SetValue(LegendFormatProperty, value); }
}
///
/// Gets or sets the outside label format.
///
public string OutsideLabelFormat
{
get { return GetValue(OutsideLabelFormatProperty); }
set { SetValue(OutsideLabelFormatProperty, value); }
}
///
/// Gets or sets the color of the inside labels.
///
public Color InsideLabelColor
{
get { return GetValue(InsideLabelColorProperty); }
set { SetValue(InsideLabelColorProperty, value); }
}
///
/// Gets or sets the inside label format.
///
public string InsideLabelFormat
{
get { return GetValue(InsideLabelFormatProperty); }
set { SetValue(InsideLabelFormatProperty, value); }
}
///
/// Gets or sets the inside label position.
///
public double InsideLabelPosition
{
get { return GetValue(InsideLabelPositionProperty); }
set { SetValue(InsideLabelPositionProperty, value); }
}
///
/// Gets or sets a value indicating whether inside labels are angled.
///
public bool AreInsideLabelsAngled
{
get { return GetValue(AreInsideLabelsAngledProperty); }
set { SetValue(AreInsideLabelsAngledProperty, value); }
}
///
/// Gets or sets the distance from the edge of the pie slice to the tick line.
///
public double TickDistance
{
get { return GetValue(TickDistanceProperty); }
set { SetValue(TickDistanceProperty, value); }
}
///
/// Gets or sets the length of the radial part of the tick line.
///
public double TickRadialLength
{
get { return GetValue(TickRadialLengthProperty); }
set { SetValue(TickRadialLengthProperty, value); }
}
///
/// Gets or sets the length of the horizontal part of the tick.
///
public double TickHorizontalLength
{
get { return GetValue(TickHorizontalLengthProperty); }
set { SetValue(TickHorizontalLengthProperty, value); }
}
///
/// Gets or sets the distance from the tick line to the outside label.
///
public double TickLabelDistance
{
get { return GetValue(TickLabelDistanceProperty); }
set { SetValue(TickLabelDistanceProperty, value); }
}
///
/// Gets or sets the exploded distance.
///
public double ExplodedDistance
{
get { return GetValue(ExplodedDistanceProperty); }
set { SetValue(ExplodedDistanceProperty, value); }
}
///
/// Gets or sets the name of the property containing the label.
///
public string LabelField
{
get { return GetValue(LabelFieldProperty); }
set { SetValue(LabelFieldProperty, value); }
}
///
/// Gets or sets the name of the property containing the value.
///
public string ValueField
{
get { return GetValue(ValueFieldProperty); }
set { SetValue(ValueFieldProperty, value); }
}
///
/// Gets or sets the name of the property containing the color.
///
public string ColorField
{
get { return GetValue(ColorFieldProperty); }
set { SetValue(ColorFieldProperty, value); }
}
///
/// Gets or sets the name of the property indicating whether the item
/// is exploded.
///
public string IsExplodedField
{
get { return GetValue(IsExplodedFieldProperty); }
set { SetValue(IsExplodedFieldProperty, value); }
}
///
/// Synchronizes the properties of this object with the underlying series object.
///
/// The series.
protected override void SynchronizeProperties(OxyPlot.Series.Series series)
{
base.SynchronizeProperties(series);
var s = (OxyPlot.Series.PieSeries)series;
s.Stroke = Stroke.ToOxyColor();
s.StrokeThickness = StrokeThickness;
s.Diameter = Diameter;
s.InnerDiameter = InnerDiameter;
s.StartAngle = StartAngle;
s.AngleSpan = AngleSpan;
s.AngleIncrement = AngleIncrement;
s.LegendFormat = LegendFormat;
s.OutsideLabelFormat = OutsideLabelFormat;
s.InsideLabelColor = InsideLabelColor.ToOxyColor();
s.InsideLabelFormat = InsideLabelFormat;
s.InsideLabelPosition = InsideLabelPosition;
s.AreInsideLabelsAngled = AreInsideLabelsAngled;
s.TickDistance = TickDistance;
s.TickRadialLength = TickRadialLength;
s.TickHorizontalLength = TickHorizontalLength;
s.TickLabelDistance = TickLabelDistance;
s.ExplodedDistance = ExplodedDistance;
s.LabelField = LabelField;
s.ValueField = ValueField;
s.ColorField = ColorField;
s.IsExplodedField = IsExplodedField;
}
}
}