using System;
using System.Collections.Generic;
using System.Text;

namespace TChart.ImageChart
{
    /// <summary>
    /// 定义X轴的数据集合
    /// </summary>
    /// <remarks>
    /// 作者: Kingthy 
    /// 日期: 2007-09-11
    /// MSN:  Kingthy@gmail.com
    /// 转载请注明原作者,当你有更新修改时如果方便的希望能发一份给我.谢谢
    /// </remarks>
    public class XAxisItemList : List<XAxisItem>
    {
        /// <summary>
        /// 
        /// </summary>
        public XAxisItemList() : base() { }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="capacity"></param>
        public XAxisItemList(int capacity) : base(capacity) { }

        /// <summary>
        /// 添加一批数据
        /// </summary>
        /// <param name="titles">轴的标题</param>
        public void AddRange(string[] titles)
        {
            foreach (string title in titles)
            {
                base.Add(new XAxisItem(title));
            }
        }

        /// <summary>
        /// 添加一批数据
        /// </summary>
        /// <param name="titles">轴的标题</param>
        /// <param name="values">轴的值</param>
        public void AddRange(string[] titles, decimal[] values)
        {
            int index = 0;
            foreach (string title in titles)
            {
                XAxisItem axis = new XAxisItem(title);
                if (values.Length > index) axis.Value = values[index];
                index++;

                base.Add(axis);
            }
        }

        /// <summary>
        /// 重置轴的值
        /// </summary>
        /// <param name="values">轴的值</param>
        public void ResetValue(int[] values)
        {
            for (int i = 0; i < values.Length; i++)
            {
                if (i >= this.Count) return;

                this[i].Value = values[i];
            }
        }

        /// <summary>
        /// 克隆数据
        /// </summary>
        /// <returns></returns>
        public XAxisItemList Clone()
        {
            XAxisItemList list = new XAxisItemList();
            foreach (XAxisItem item in this)
            {
                list.Add(item.Clone());
            }
            return list;
        }
    }
}
