using System.Data;
using System.Text;

namespace Stat.Report
{
    /// <summary>
    /// 线性报表
    /// </summary>
    public class Rp_2_SLine
    {
        /// <summary>
        /// 最近流量趋势(PV or IP or UV ...)
        /// </summary>
        /// <param name="dt">2列（0：小时点，1：值）</param>
        /// <param name="caption">标题</param>
        /// <param name="xAxisName">X轴名称</param>
        /// <param name="yAxisName">Y轴名称</param>
        /// <param name="decimalPrecision">值的精度（0）</param>
        /// <param name="formatNumberScale">刻度（0）</param>
        /// <returns></returns>

        public static string GetXML_vHour(DataTable dt, string caption, string xAxisName, string yAxisName, int decimalPrecision, int formatNumberScale)
        {
            StringBuilder strXML = new System.Text.StringBuilder();
            strXML.Append("<graph caption='" + caption + "' xAxisName='" + xAxisName + "' yAxisName='" + yAxisName + "' decimalPrecision='" + decimalPrecision + "' formatNumberScale='" + formatNumberScale + "'>");

            if (dt != null)
            {
                string[] c = Plugin.Common.RpColor();
                int cj = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    strXML.Append("<set name='" + dt.Rows[i][0].ToString() + " 时' value='" + dt.Rows[i][1].ToString() + "' color='" + c[cj].ToString() + "' />");
                    cj++;
                    cj = cj >= (c.GetLength(0) - 1) ? 0 : cj; //颜色编号
                }
            }
            strXML.Append("</graph>");

            return strXML.ToString();
        }
    }
}
