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

namespace Navigator.MarketDataModel
{
  public class PreMarketModel
  {
    private PreMarketModel()
    {
    }
    public static CompositeDataSource Elements(List<PremarketElement> premarketData)
    {
      if (null == premarketData) return null;
      CompositeDataSource compositeDataSource;

      List<long> enumeration=new List<long>();
      for(int index=0;index<premarketData.Count;index++)enumeration.Add(index);
      var xData = new EnumerableDataSource<long>(enumeration.Select(x => x));
      xData.SetXMapping(x => x);

//      var xData = new EnumerableDataSource<DateTime>(premarketData.Select(x => x.Timestamp));
//      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(premarketData.Select(y => y.ChangePercent));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
  }
}
