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

namespace Navigator.MarketDataModel
{
  public class EconomicIndicatorsModel
  {
    private EconomicIndicatorsModel()
    {
    }
    public static CompositeDataSource Elements(EconomicIndicators economicIndicators)
    {
      if (null == economicIndicators) return null;
      CompositeDataSource compositeDataSource;
      var xData = new EnumerableDataSource<DateTime>(economicIndicators.Select(x => new DateTime(x.Year,1, 1)));
      xData.SetXMapping(x => (x.Ticks / 10000000000.0));
      var yData = new EnumerableDataSource<double>(economicIndicators.Select(y => y.IndicatorValue));
      yData.SetYMapping(y => y);
      compositeDataSource = xData.Join(yData);
      return compositeDataSource;
    }
  }
}
