using System;

namespace SilverlightApplication1
{
    public class ChartViewModel
    {
        private Random rand = new Random(DateTime.Now.Millisecond);
        private ChartDataCollection data;

        public ChartDataCollection Data
        {
            get
            {
                if (data == null)
                {
                    data = new ChartDataCollection();

                    data.Add(CreateChartDataItem("Test {0}"));
                    data.Add(CreateChartDataItem("Foo {0}"));
                    data.Add(CreateChartDataItem("Bar {0}"));
                }

                return data;
            }
        }

        private ChartDataItem CreateChartDataItem(string menuItemTextFormat)
        {
            ChartDataItem item = new ChartDataItem();

            item.YValue = rand.Next(10, 100);
            for (int i = 0; i < rand.Next(2, 5); i++)
            {
                item.MenuItems.Add(new MenuItem() { Text = string.Format(menuItemTextFormat, i) });
            }

            return item;
        }
    }
}
