using System;
using CommunityToolkit.Mvvm.ComponentModel;
using Eremex.AvaloniaUI.Charts;

namespace PortfolioManager.DataSeriesViewModels
{
  public partial class CompositeDataSource : ObservableObject
  {
    [ObservableProperty] ISeriesDataAdapter dataAdapter;
    public (DateTime[],double[]) ToXYData()
    {
      double[] values = default;
      DateTime[] dates = default;

      if (null == DataAdapter) return (dates, values);
      values = new double[DataAdapter.ItemCount];
      dates = new DateTime[DataAdapter.ItemCount];
      for (int index = 0; index < DataAdapter.ItemCount; index++)
      {
        values[index] = DataAdapter.GetNumericalValue(index, SeriesDataMemberType.Value);
        dates[index] = DataAdapter.GetDateTimeValue(index, SeriesDataMemberType.Value1);
      }
      return (dates, values);
    }
  }
}