// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2014 OxyPlot contributors
//
//
// This is a Avalonia wrapper of OxyPlot.BarSeriesBase
//
// --------------------------------------------------------------------------------------------------------------------
using Avalonia;
namespace OxyPlot.Avalonia
{
using global::Avalonia.Media;
using OxyPlot.Series;
///
/// This is a Avalonia wrapper of OxyPlot.BarSeriesBase
///
public class BarSeriesBase : CategorizedSeries
{
///
/// Identifies the dependency property.
///
public static readonly StyledProperty BaseValueProperty = AvaloniaProperty.Register(nameof(BaseValue), 0.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty ColorFieldProperty = AvaloniaProperty.Register(nameof(ColorField), null);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty FillColorProperty = AvaloniaProperty.Register(nameof(FillColor), MoreColors.Automatic);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty IsStackedProperty = AvaloniaProperty.Register(nameof(IsStacked), false);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty LabelFormatStringProperty = AvaloniaProperty.Register(nameof(LabelFormatString), null);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty LabelMarginProperty = AvaloniaProperty.Register(nameof(LabelMargin), 2.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty LabelPlacementProperty = AvaloniaProperty.Register(nameof(LabelPlacement), LabelPlacement.Outside);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty NegativeFillColorProperty = AvaloniaProperty.Register(nameof(NegativeFillColor), MoreColors.Undefined);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty StackGroupProperty = AvaloniaProperty.Register(nameof(StackGroup), string.Empty);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty StrokeColorProperty = AvaloniaProperty.Register(nameof(StrokeColor), Colors.Black);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty StrokeThicknessProperty = AvaloniaProperty.Register(nameof(StrokeThickness), 0.0);
///
/// Identifies the dependency property.
///
public static readonly StyledProperty ValueFieldProperty = AvaloniaProperty.Register(nameof(ValueField), null);
///
/// Initializes static members of the class.
///
static BarSeriesBase()
{
TrackerFormatStringProperty.OverrideMetadata(typeof(BarSeriesBase), new StyledPropertyMetadata(OxyPlot.Series.BarSeries.DefaultTrackerFormatString));
BaseValueProperty.Changed.AddClassHandler(AppearanceChanged);
ColorFieldProperty.Changed.AddClassHandler(DataChanged);
FillColorProperty.Changed.AddClassHandler(AppearanceChanged);
IsStackedProperty.Changed.AddClassHandler(AppearanceChanged);
LabelFormatStringProperty.Changed.AddClassHandler(AppearanceChanged);
LabelMarginProperty.Changed.AddClassHandler(AppearanceChanged);
LabelPlacementProperty.Changed.AddClassHandler(AppearanceChanged);
NegativeFillColorProperty.Changed.AddClassHandler(AppearanceChanged);
StackGroupProperty.Changed.AddClassHandler(AppearanceChanged);
StrokeColorProperty.Changed.AddClassHandler(AppearanceChanged);
StrokeThicknessProperty.Changed.AddClassHandler(AppearanceChanged);
ValueFieldProperty.Changed.AddClassHandler(DataChanged);
TrackerFormatStringProperty.Changed.AddClassHandler(AppearanceChanged);
}
///
/// Gets or sets BaseValue.
///
public double BaseValue
{
get
{
return GetValue(BaseValueProperty);
}
set
{
SetValue(BaseValueProperty, value);
}
}
///
/// Gets or sets the color field.
///
/// The color field.
public string ColorField
{
get
{
return GetValue(ColorFieldProperty);
}
set
{
SetValue(ColorFieldProperty, value);
}
}
///
/// Gets or sets the color of the fill color.
///
/// The color of the fill color.
public Color FillColor
{
get
{
return GetValue(FillColorProperty);
}
set
{
SetValue(FillColorProperty, value);
}
}
///
/// Gets or sets a value indicating whether the series is stacked.
///
public bool IsStacked
{
get
{
return GetValue(IsStackedProperty);
}
set
{
SetValue(IsStackedProperty, value);
}
}
///
/// Gets or sets the label format string.
///
/// The label format string.
public string LabelFormatString
{
get
{
return GetValue(LabelFormatStringProperty);
}
set
{
SetValue(LabelFormatStringProperty, value);
}
}
///
/// Gets or sets the label margin.
///
/// The label margin.
public double LabelMargin
{
get
{
return GetValue(LabelMarginProperty);
}
set
{
SetValue(LabelMarginProperty, value);
}
}
///
/// Gets or sets the label placement.
///
/// The label placement.
public LabelPlacement LabelPlacement
{
get
{
return GetValue(LabelPlacementProperty);
}
set
{
SetValue(LabelPlacementProperty, value);
}
}
///
/// Gets or sets NegativeFillColor.
///
public Color NegativeFillColor
{
get
{
return GetValue(NegativeFillColorProperty);
}
set
{
SetValue(NegativeFillColorProperty, value);
}
}
///
/// Gets or sets the stack group.
///
/// The stack group.
public string StackGroup
{
get
{
return GetValue(StackGroupProperty);
}
set
{
SetValue(StackGroupProperty, value);
}
}
///
/// Gets or sets the stroke color.
///
public Color StrokeColor
{
get
{
return GetValue(StrokeColorProperty);
}
set
{
SetValue(StrokeColorProperty, value);
}
}
///
/// Gets or sets the stroke thickness.
///
public double StrokeThickness
{
get
{
return GetValue(StrokeThicknessProperty);
}
set
{
SetValue(StrokeThicknessProperty, value);
}
}
///
/// Gets or sets the value field.
///
public string ValueField
{
get
{
return GetValue(ValueFieldProperty);
}
set
{
SetValue(ValueFieldProperty, value);
}
}
///
/// Creates the model.
///
/// The series.
public override OxyPlot.Series.Series CreateModel()
{
SynchronizeProperties(InternalSeries);
return InternalSeries;
}
///
/// Synchronizes the properties.
///
/// The series.
protected override void SynchronizeProperties(OxyPlot.Series.Series series)
{
base.SynchronizeProperties(series);
var s = (OxyPlot.Series.BarSeries)series;
s.BaseValue = BaseValue;
s.ColorField = ColorField;
s.FillColor = FillColor.ToOxyColor();
s.IsStacked = IsStacked;
s.NegativeFillColor = NegativeFillColor.ToOxyColor();
s.StrokeColor = StrokeColor.ToOxyColor();
s.StrokeThickness = StrokeThickness;
s.StackGroup = StackGroup;
s.ValueField = ValueField;
s.LabelFormatString = LabelFormatString;
s.LabelMargin = LabelMargin;
s.LabelPlacement = LabelPlacement;
}
}
}