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

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