using System;
using System.Collections.Generic;
using System.Linq;
using DataDisplay.DataSource;
using MarketData.MarketDataModel.GainLoss;

namespace Navigator.MarketDataModel
{
  public class GainLossSeriesModel
  {
    private GainLossSeriesModel()
    {
    }
    public static CompositeDataSource Elements(GainLossCompoundModelCollection gainLossSeriesData)
    {
      if (null == gainLossSeriesData) return null;
      CompositeDataSource compositeDataSource;
      var xData = new EnumerableDataSource<DateTime>(gainLossSeriesData.Select(x => x.Date.Date));
      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(gainLossSeriesData.Select(y => y.TotalGainLoss));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
  }
}
