BarSeries.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="BarSeries.cs" company="OxyPlot">
  3. // Copyright (c) 2014 OxyPlot contributors
  4. // </copyright>
  5. // <summary>
  6. // This is a Avalonia wrapper of OxyPlot.BarSeries
  7. // </summary>
  8. // --------------------------------------------------------------------------------------------------------------------
  9. using Avalonia;
  10. namespace OxyPlot.Avalonia
  11. {
  12. using OxyPlot.Series;
  13. /// <summary>
  14. /// This is a Avalonia wrapper of OxyPlot.BarSeries
  15. /// </summary>
  16. public class BarSeries : BarSeriesBase<BarItem>
  17. {
  18. /// <summary>
  19. /// Identifies the <see cref="BarWidth"/> dependency property.
  20. /// </summary>
  21. public static readonly StyledProperty<double> BarWidthProperty = AvaloniaProperty.Register<BarSeries, double>(nameof(BarWidth), 1.0);
  22. /// <summary>
  23. /// Initializes a new instance of the <see cref="BarSeries" /> class.
  24. /// </summary>
  25. public BarSeries()
  26. {
  27. InternalSeries = new OxyPlot.Series.BarSeries();
  28. }
  29. /// <summary>
  30. /// Gets or sets the bar width.
  31. /// </summary>
  32. public double BarWidth
  33. {
  34. get
  35. {
  36. return GetValue(BarWidthProperty);
  37. }
  38. set
  39. {
  40. SetValue(BarWidthProperty, value);
  41. }
  42. }
  43. /// <summary>
  44. /// Synchronizes the properties.
  45. /// </summary>
  46. /// <param name="series">The series.</param>
  47. protected override void SynchronizeProperties(OxyPlot.Series.Series series)
  48. {
  49. base.SynchronizeProperties(series);
  50. var s = (OxyPlot.Series.BarSeries)series;
  51. s.BarWidth = BarWidth;
  52. }
  53. static BarSeries()
  54. {
  55. BarWidthProperty.Changed.AddClassHandler<BarSeries>(AppearanceChanged);
  56. }
  57. }
  58. }