void InitChart_AppRunsWithoutVersion(DbConnection conn, DBWorker worker) { DbCommand cmd = conn.CreateCommand(); InitQueryForUsageReportTable("select s.AppName, count(s.ID) as NumSessions, avg(" + worker.GetDateDiffExpression("s.StartTime", "s.EndTime", "s") + ") as Dur from " + svc.UsageReportTableName + " as s ", cmd, "group by s.AppName order by count(s.ID) DESC"); DataTable dt = LoadDataTableFromCommand(cmd); AddDurationColumnFromSeconds(dt, "Duration", 2); Chart1.DataSource = dt; Chart1.Series["Series1"].XValueMember = "AppName"; Chart1.Series["Series1"].YValueMembers = "NumSessions"; Chart1.Series["Series1"].Label = "#VALY\n(#PERCENT)"; SetAxisProperties(Chart1.ChartAreas[0].AxisX, "Number Of Runs"); ChartArea ca = Chart1.ChartAreas.Add("duration"); Series s = Chart1.Series.Add("duration"); s.ChartArea = "duration"; s.XValueMember = "AppName"; s.YValueMembers = "Duration"; s.YValueType = ChartValueType.DateTime; s.IsValueShownAsLabel = true; s.LabelFormat = "HH:mm"; ca.AxisY.Minimum = 0; ca.AxisY.LabelStyle.Format = "HH:mm"; ca.AxisY.LabelStyle.Enabled = true; SetAxisProperties(ca.AxisX, "Avg Duration"); AlignChartAreaTo(ca, Chart1.ChartAreas[0].Name); Chart1.DataBind(); }
void InitChart_FeatureUsageByDay(DbConnection conn, DBWorker worker) { DbCommand cmd = conn.CreateCommand(); string dateFormatStr = worker.GetConvertDateToStringExpression("f.StartTime", worker.GetDateFormatString_yyyy_mm_dd()); InitQueryForFeatureTable("select " + dateFormatStr + " as RunDate, count(f.Name) as NumSessions, avg(" + worker.GetDateDiffExpression("f.StartTime", "f.EndTime", "s") + ") as Dur from " + svc.UsageReportFeatureTableName + " as f ", cmd, " group by " + dateFormatStr + " order by " + dateFormatStr + ";"); DataTable dt = LoadDataTableFromCommand(cmd); AddDurationColumnFromSeconds(dt, "Duration", 2); Chart1.DataSource = dt; Chart1.Series["Series1"].XValueMember = "RunDate"; Chart1.Series["Series1"].YValueMembers = "NumSessions"; Chart1.Series["Series1"].Label = "#VALY\n(#PERCENT)"; Chart1.Series["Series1"].ChartType = SeriesChartType.Line; SetAxisProperties(Chart1.ChartAreas[0].AxisX, "Feature Usage Count By Day"); ChartArea ca = Chart1.ChartAreas.Add("duration"); Series s = Chart1.Series.Add("duration"); s.ChartArea = "duration"; s.XValueMember = "RunDate"; s.YValueMembers = "Duration"; s.YValueType = ChartValueType.DateTime; s.IsValueShownAsLabel = true; s.LabelFormat = "HH:mm"; ca.AxisY.Minimum = 0; ca.AxisY.LabelStyle.Format = "HH:mm"; ca.AxisY.LabelStyle.Enabled = true; SetAxisProperties(ca.AxisX, "Avg Duration"); AlignChartAreaTo(ca, Chart1.ChartAreas[0].Name); Chart1.DataBind(); }