/// <summary> /// 获取当日广告点击图形 /// </summary> /// <param name="userid"></param> /// <returns></returns> public EChartInfoJson GetAdBrowseHour(int userid) { ChartPara cp = new ChartPara(); cp.CommandText = string.Format(@"select * from ( select AdId, count(distinct(ClientIp)) as clickcount, left(convert(varchar(10), CreateDate, 108), 2) as time from[dbo].[AdBrowse] where userid={0} group by AdId, left(convert(varchar(10), CreateDate, 108), 2) ) a order by a.time asc", userid); //时间数据 var hours = CommonBLL.GetHourTable(); //数据 DataTable table = acc.GetTable(cp); //图形 Entity.EChartInfoJson chart = new Entity.EChartInfoJson(); chart.legend = new List <string>(); chart.xAxis = hours; chart.series = new List <Entity.serie>(); var adlist = AdPageInfoBLL.Instance.GetModels(new AdPageInfoPara() { UserId = userid }); chart.xAxis = hours; foreach (var item in adlist) { chart.legend.Add(item.Title); Entity.serie data = new Entity.serie(); data.name = item.Title; data.data = new List <string>(); data.stack = "浏览量"; data.type = "line"; foreach (var hour in hours) { var row = table.Select(string.Format("AdId={0} and time='{1}'", item.Id, hour)); if (row.Length == 0) { data.data.Add("0"); } else { data.data.Add(row[0]["clickcount"].ToString()); } } chart.series.Add(data); } return(chart); }
/// <summary> /// 获取当日广告点击图形 /// </summary> /// <param name="userid"></param> /// <returns></returns> public static EChartInfoJson GetAdBrowseHour(DataTable table, int time = 0) { //时间数据 var hours = CommonBLL.GetHourTable(time); //图形 Entity.EChartInfoJson chart = new Entity.EChartInfoJson(); chart.legend = new List <string>(); chart.xAxis = hours; chart.series = new List <Entity.serie>(); chart.xAxis = hours; Entity.serie data = new Entity.serie(); data.name = "浏览次数(PV)"; data.data = new List <string>(); data.stack = "浏览次数(PV)"; data.type = "line"; Entity.serie data1 = new Entity.serie(); data1.name = "独立访客(UV)"; data1.data = new List <string>(); data1.stack = "独立访客(UV)"; data1.type = "line"; Entity.serie data2 = new Entity.serie(); data2.name = "IP"; data2.data = new List <string>(); data2.stack = "IP"; data2.type = "line"; foreach (var hour in hours) { var row = table.Select(string.Format("time='{0}'", hour)); if (row.Length == 0) { data.data.Add("0"); data1.data.Add("0"); data2.data.Add("0"); } else { data.data.Add(row[0]["pvcount"].ToString()); data1.data.Add(row[0]["uvcount"].ToString()); data2.data.Add(row[0]["ipcount"].ToString()); } } chart.series.Add(data); chart.series.Add(data1); chart.series.Add(data2); return(chart); }