using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.Charting;

namespace StackedBarsListDecimal
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.FillSampleChartData();
        }

        private void FillSampleChartData()
        {
            StackedBarSeriesDefinition definition = new StackedBarSeriesDefinition();
            SeriesMapping sm = new SeriesMapping() { SeriesDefinition = definition };
            sm.ItemMappings.Add(new ItemMapping(string.Empty, DataPointMember.YValue));
            sm.CollectionIndex = 0;
            RadChart1.SeriesMappings.Add(sm);

            sm = new SeriesMapping() { SeriesDefinition = definition };
            sm.ItemMappings.Add(new ItemMapping(string.Empty, DataPointMember.YValue));
            sm.CollectionIndex = 1;
            RadChart1.SeriesMappings.Add(sm);

            sm = new SeriesMapping() { SeriesDefinition = definition };
            sm.ItemMappings.Add(new ItemMapping(string.Empty, DataPointMember.YValue));
            sm.CollectionIndex = 2;
            RadChart1.SeriesMappings.Add(sm);

            sm = new SeriesMapping() { SeriesDefinition = definition };
            sm.ItemMappings.Add(new ItemMapping(string.Empty, DataPointMember.YValue));
            sm.CollectionIndex = 3;
            RadChart1.SeriesMappings.Add(sm);

            sm = new SeriesMapping() { SeriesDefinition = definition };
            sm.ItemMappings.Add(new ItemMapping(string.Empty, DataPointMember.YValue));
            sm.CollectionIndex = 4;
            RadChart1.SeriesMappings.Add(sm);

            List<decimal[]> data = new List<decimal[]>();
            data.Add(new decimal[] { 30, 30, 30, 30, 30 });
            data.Add(new decimal[] { 40, 40, 40, 40, 40 });
            data.Add(new decimal[] { 50, 50, 50, 50, 50 });
            data.Add(new decimal[] { 60, 60, 60, 60, 60 });
            data.Add(new decimal[] { 70, 70, 70, 70, 70 });

            RadChart1.DefaultView.ChartArea.AxisY.AutoRange = false;
            RadChart1.DefaultView.ChartArea.AxisY.MaxValue = 300;
            RadChart1.DefaultView.ChartArea.AxisY.MinValue = 0;
            RadChart1.DefaultView.ChartArea.AxisY.Step = 50;

            this.RadChart1.ItemsSource = data;
        }
    }
}
