XYAxisSeries.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="XYAxisSeries.cs" company="OxyPlot">
  3. // Copyright (c) 2014 OxyPlot contributors
  4. // </copyright>
  5. // <summary>
  6. // Abstract base class for series that use X and Y axes.
  7. // </summary>
  8. // --------------------------------------------------------------------------------------------------------------------
  9. using Avalonia;
  10. namespace OxyPlot.Avalonia
  11. {
  12. /// <summary>
  13. /// Abstract base class for series that use X and Y axes.
  14. /// </summary>
  15. public abstract class XYAxisSeries : ItemsSeries
  16. {
  17. /// <summary>
  18. /// Identifies the <see cref="XAxisKey"/> dependency property.
  19. /// </summary>
  20. public static readonly StyledProperty<string> XAxisKeyProperty = AvaloniaProperty.Register<XYAxisSeries, string>(nameof(XAxisKey), null);
  21. /// <summary>
  22. /// Identifies the <see cref="YAxisKey"/> dependency property.
  23. /// </summary>
  24. public static readonly StyledProperty<string> YAxisKeyProperty = AvaloniaProperty.Register<XYAxisSeries, string>(nameof(YAxisKey), null);
  25. /// <summary>
  26. /// Initializes static members of the <see cref="XYAxisSeries"/> class.
  27. /// </summary>
  28. static XYAxisSeries()
  29. {
  30. TrackerFormatStringProperty.OverrideMetadata(typeof(XYAxisSeries), new StyledPropertyMetadata<string>(OxyPlot.Series.XYAxisSeries.DefaultTrackerFormatString));
  31. XAxisKeyProperty.Changed.AddClassHandler<XYAxisSeries>(AppearanceChanged);
  32. YAxisKeyProperty.Changed.AddClassHandler<XYAxisSeries>(AppearanceChanged);
  33. TrackerFormatStringProperty.Changed.AddClassHandler<XYAxisSeries>(AppearanceChanged);
  34. }
  35. /// <summary>
  36. /// Gets or sets the x-axis key.
  37. /// </summary>
  38. public string XAxisKey
  39. {
  40. get
  41. {
  42. return GetValue(XAxisKeyProperty);
  43. }
  44. set
  45. {
  46. SetValue(XAxisKeyProperty, value);
  47. }
  48. }
  49. /// <summary>
  50. /// Gets or sets the y axis key.
  51. /// </summary>
  52. public string YAxisKey
  53. {
  54. get
  55. {
  56. return GetValue(YAxisKeyProperty);
  57. }
  58. set
  59. {
  60. SetValue(YAxisKeyProperty, value);
  61. }
  62. }
  63. /// <summary>
  64. /// Synchronizes the properties.
  65. /// </summary>
  66. /// <param name="series">The series.</param>
  67. protected override void SynchronizeProperties(OxyPlot.Series.Series series)
  68. {
  69. base.SynchronizeProperties(series);
  70. var s = (OxyPlot.Series.XYAxisSeries)series;
  71. s.XAxisKey = XAxisKey;
  72. s.YAxisKey = YAxisKey;
  73. }
  74. }
  75. }