using C1.Xaml.Chart;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace ChartSamples
{
    public sealed partial class RangeColumnSeries : UserControl
    {
        public RangeColumnSeries()
        {
            this.InitializeComponent();

            // invert so bars run vertically
            c1Chart1.View.Inverted = true;

            // set x-axis to display time
            c1Chart1.View.AxisX.IsTime = true;

            // can use doubles on y axis
            c1Chart1.View.AxisY.IsTime = false; // default is false

            // create and populate each series
            HighLowSeries ds1 = new HighLowSeries() { Label = "Left Room" };
            ds1.XValuesSource = new DateTime[] { new DateTime(2013, 10, 1), new DateTime(2013, 10, 1) };
            ds1.LowValuesSource = new double[] { 10, 30 };
            ds1.HighValuesSource = new double[] { 20, 50 };
            ds1.PointTooltipTemplate = this.Resources["label"] as DataTemplate;

            HighLowSeries ds2 = new HighLowSeries() { Label = "Left Early" };
            ds2.XValuesSource = new DateTime[] { new DateTime(2013, 9, 15), new DateTime(2013, 10, 11), new DateTime(2013, 10, 16) };
            ds2.LowValuesSource = new double[] { 40, 53, 46 };
            ds2.HighValuesSource = new double[] { 60, 60, 60 };
            ds2.PointTooltipTemplate = this.Resources["label"] as DataTemplate;

            HighLowSeries ds3 = new HighLowSeries() { Label = "Arrived Late" };
            ds3.XValuesSource = new DateTime[] { new DateTime(2013, 9, 5), new DateTime(2013, 10, 16) };
            ds3.LowValuesSource = new double[] { 0, 2 };
            ds3.HighValuesSource = new double[] { 10, 20 };
            ds3.PointTooltipTemplate = this.Resources["label"] as DataTemplate;

            // set bar size 
            ds3.SymbolSize = new Size(30, 30);

            // add series to chart
            c1Chart1.Data.Children.Add(ds1);
            c1Chart1.Data.Children.Add(ds2);
            c1Chart1.Data.Children.Add(ds3);

            // set axis titles
            c1Chart1.View.AxisY.Title = "Minutes";
            //c1Chart1.View.AxisX.Title = "Day";

            // adjust grid lines, etc
            c1Chart1.View.AxisY.MajorUnit = 20;
            c1Chart1.View.PlotBackground = new SolidColorBrush(Colors.White);
            c1Chart1.View.AxisY.MinorGridStrokeThickness = 1;
        }
    }
}
