using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
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;
using C1.Xaml.Chart;
using Windows.UI;

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

namespace SalesDashboard
{
    public sealed partial class SalesByRegion : UserControl
    {
        public SalesByRegion()
        {
            this.InitializeComponent();
        }

        private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            // setup chart
            c1Chart1.BeginUpdate();
            c1Chart1.View.AxisX.Min = -180;
            c1Chart1.View.AxisX.Max = 180;
            c1Chart1.View.AxisY.Min = -90;
            c1Chart1.View.AxisY.Max = 90;
            c1Chart1.View.AxisX.AxisLine = new Windows.UI.Xaml.Shapes.Line() { StrokeThickness = 0 };
            c1Chart1.View.AxisY.AxisLine = new Windows.UI.Xaml.Shapes.Line() { StrokeThickness = 0 };
            c1Chart1.View.AxisX.Foreground = new SolidColorBrush(Colors.Transparent);
            c1Chart1.View.AxisY.Foreground = new SolidColorBrush(Colors.Transparent);
            c1Chart1.View.AxisX.MajorGridStrokeThickness = 0;
            c1Chart1.View.AxisX.MinorGridStrokeThickness = 0;
            // set series in code
            Data.SampleDataSource dataSource = this.DataContext as Data.SampleDataSource;
            if (dataSource != null)
            {
                foreach (BubbleSeries bs in dataSource.SalesByRegion)
                {
                    bs.PointTooltipTemplate = this.Resources["lbl"] as DataTemplate;
                    c1Chart1.Data.Children.Add(bs);
                }
            }
            c1Chart1.EndUpdate();
        }
    }
}
