using System.Collections.Generic;
using System.Text;
namespace Stat.Report
{
    /// <summary>
    /// 线性报表
    /// </summary>
    public class Rp_3_SLine
    {

        /// <summary>
        /// 小时流量趋势
        /// </summary>
        /// <param name="dt">数据源</param>
        /// <param name="caption">标题</param>
        /// <param name="subcaption">副标题</param>
        /// <param name="xAxisName">X轴名称</param>
        /// <param name="yAxisName">Y轴名称</param>
        /// <param name="yAxisMinValue">Y轴最小值（15000）</param>
        /// <param name="showValues">（0）</param>
        /// <param name="numberSuffix"></param>
        /// <returns></returns>
        public static string GetXML_vHour(List<Model.StatItem> list, string caption, string subcaption, string xAxisName, string yAxisName, int yAxisMinValue, string numberSuffix, int showValues)
        {

            StringBuilder strXML = new System.Text.StringBuilder();
            strXML.Append("<chart caption='" + caption + "' subcaption='" + subcaption + "' xAxisName='" + xAxisName + "' yAxisName='" + yAxisName + "' yAxisMinValue='" + yAxisMinValue + "'  numberSuffix='" + numberSuffix + "' showValues='" + showValues + "'");
            strXML.Append(" alternateHGridColor='FCB541' alternateHGridAlpha='15' divLineColor='FCB541' divLineAlpha='40'");
            strXML.Append(" labelStep='2'");
            strXML.Append(" canvasBorderColor='F7BD62' baseFontColor='000000' lineColor='FCB541' bgColor='FFFFFF' showBorder='0'>");

            if (list != null)
            {
                string[] colorList = Plugin.Common.RpColor();
                int cj = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    if (!((list[i].PvCount == 0) && (i > list.Count - 3)))
                    {
                        strXML.Append("  <set label='" + list[i].Name + ":00' value='" + list[i].PvCount + "' color='" + colorList[cj].ToString() + "' toolText='" + list[i].Name + "时 流量：" + list[i].PvCount + " " + numberSuffix + "' />");
                    }
                    cj++;
                    cj = cj >= (colorList.GetLength(0) - 1) ? 0 : cj;
                }
            }
            strXML.Append("<styles>");
            strXML.Append(" <definition>");
            strXML.Append("    <style name='Anim1' type='animation' param='_xscale' start='0' duration='1' />");
            strXML.Append("    <style name='Anim2' type='animation' param='_alpha' start='0' duration='0.6' />");
            strXML.Append("    <style name='DataShadow' type='Shadow' alpha='40'/>");
            strXML.Append(" </definition>");
            strXML.Append("<application>");
            strXML.Append("    <apply toObject='DIVLINES' styles='Anim1' />");
            strXML.Append("    <apply toObject='HGRID' styles='Anim2' />");
            strXML.Append("    <apply toObject='DATALABELS' styles='DataShadow,Anim2' />");
            strXML.Append("</application>");
            strXML.Append("</styles>");
            strXML.Append("</chart>");
            return strXML.ToString();

        }
    }
}
