using System.Text;
using System.Collections.Generic;
namespace Stat.Report
{
    public class Map_China
    {
        public static string GetXML(List<Model.StatItem> list)
        {
            long colorRangeValueA = 100, colorRangeValueB = 500, colorRangeValueC = 1000, colorRangeValueD = 5000000000;
            //
            if (list[0].PvCount != list[(list.Count - 1)].PvCount)
            {
                colorRangeValueA = list[list.Count - 1].PvCount;//最小值               
                colorRangeValueD = list[0].PvCount + 1; //最大值
                //
                colorRangeValueA = colorRangeValueA == 0 ? 1 : colorRangeValueA;
                colorRangeValueD = colorRangeValueD < 10 ? 10 : colorRangeValueD;
                //
                colorRangeValueB = colorRangeValueA + (colorRangeValueD / 4);
                colorRangeValueC = colorRangeValueB + (colorRangeValueD / 4);
            }
            //
            StringBuilder strXML = new System.Text.StringBuilder();


            strXML.Append("<map borderColor='005879' fillColor='D7F4FF' labelSepChar=': ' baseFontSize='9' legendPosition='Bottom' >");

            strXML.Append("<colorRange>");
            strXML.Append("<color minValue='0' maxValue='" + colorRangeValueA + "' displayValue='PV : 小于 " + colorRangeValueA + " ' color='F0FAFF' />");
            strXML.Append("<color minValue='" + colorRangeValueA + "' maxValue='" + colorRangeValueB + "' displayValue='PV :" + colorRangeValueA + " - " + colorRangeValueB + " ' color='F9C3C4' />");
            strXML.Append("<color minValue='" + colorRangeValueB + "' maxValue='" + colorRangeValueC + "' displayValue='PV :" + colorRangeValueB + " - " + colorRangeValueC + " ' color='F47579' />");
            strXML.Append("<color minValue='" + colorRangeValueC + "' maxValue='" + colorRangeValueD + "' displayValue='PV : 大于 " + colorRangeValueC + " ' color='EE0008' />");
            strXML.Append("</colorRange>");

            strXML.Append("<data>");

            foreach (Model.StatItem item in list)
            {
                strXML.Append("<entity id='" + item.AreaNo + "' value='" + item.PvCount + "' toolText='" + item.Name + "：" + item.PvCount + " PV' />");
            }

            strXML.Append("</data>");
            strXML.Append("</map>");
            return strXML.ToString();
        }
    }
}
