Exemplo n.º 1
0
        void InitChart_AppRunsWithVersion(DbConnection conn, DBWorker worker)
        {
            DbCommand cmd = conn.CreateCommand();

            string floatToStrExpr = worker.GetConvertFloatToStringExpression("s.AppVersion", -1, 1);

            InitQueryForUsageReportTable("select s.AppName+' v'+" + floatToStrExpr + " as App, 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,s.AppVersion order by count(s.ID) DESC");

            DataTable dt = LoadDataTableFromCommand(cmd);

            AddDurationColumnFromSeconds(dt, "Duration", 2);

            Chart1.DataSource = dt;
            Chart1.Series["Series1"].XValueMember  = "App";
            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        = "App";
            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();
        }