private void DrowWaterGraph(int calc_count, int user_id, string start_time, System.Web.UI.DataVisualization.Charting.Chart cht) { DateTime end_dt = DateTime.Today; DateTime start_dt = end_dt.AddDays(-1 * calc_count); cht.Series.Add("series1"); cht.Series["series1"].XValueType = System.Web.UI.DataVisualization.Charting.ChartValueType.Int32; //cht.Series["series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line; cht.ChartAreas[0].AxisX.LabelStyle.Enabled = false; string str = "select w.intake_day , sum(w.intake_value) from [kaigoryoku].[dbo].[T_WaterIntake] w "; str = str + "group by w.riyousya_id , w.intake_day, w.intake_time_start "; str = str + "having w.riyousya_id = " + user_id; str = str + " and w.intake_day between '" + start_dt + "' and '" + end_dt + "' "; str = str + " and w.intake_time_start = '" + start_time + "'"; str = str + "order by w.intake_day "; clsDataBase db = new clsDataBase(main.GetConnectionString()); SqlDataReader reader = db.GetReader(str); while (reader.Read()) { string tmp_dt = reader.GetValue(0).ToString(); cht.Series["series1"].Points.AddXY(tmp_dt.Substring(1, 10), reader.GetValue(1)); } db.closedb(); }
void setPreview() { if (lstGraphic.SelectedItem == null) { return; } try { var graph = (TabloidConfigGraph)lstGraphic.SelectedItem; var sqlSet = TabloidGraphHelper.GetSQL(_view, graph, "", null);//find sql sqlSet.Select.Where = string.Format("deleted_{0}=0", _view); var data = TabloidGraphHelper.GetData(graph, _view, sqlSet.Select.Command, Program.AppSet.ConnectionString); var chart = new System.Web.UI.DataVisualization.Charting.Chart(); chart.Width = imgGraphic.Width; chart.Height = imgGraphic.Height; string champX = sqlSet.Select.GroupBy; TabloidGraphHelper.GetChart(_view, graph, ref champX, chart, data); using (MemoryStream stream = new MemoryStream()) { chart.SaveImage(stream, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png); imgGraphic.Image = Image.FromStream(stream); } } catch (Exception ex) { MetroMessageBox.Show(this, ex.Message, Properties.Resources.Erreur, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ActionResult CrashProbabilityChart(int id) { var chart = new System.Web.UI.DataVisualization.Charting.Chart(); var crashes = chart.Series.Add("Occurrences"); crashes.ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line; ExceptionGroupRepository exceptionGroupRepository = new ExceptionGroupRepository(); foreach (var pair in exceptionGroupRepository.GetCrashStatisticsForExceptionGroup(id)) { crashes.Points.AddXY(pair.Item1, pair.Item2); } chart.Width = 800; chart.Height = 300; chart.RenderType = System.Web.UI.DataVisualization.Charting.RenderType.ImageTag; chart.ChartAreas.Add("Series 1").AxisX.Interval = 1; using (var ms = new MemoryStream()) { chart.SaveImage(ms, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png); ms.Position = 0; return(File(ms.ToArray(), "image/png", "mychart.png")); } }
protected void Display(System.Web.UI.DataVisualization.Charting.Chart s) { string ss = ""; for (int i = 0; i < s.Titles.Count(); i++) { ss += s.Titles[i].Text + "; "; } tStato.Text = ss.ToString(); }
private void ReDrawChart() { try { if (this.pChart.Series.Count != 0) { this.pChart.Series.Clear(); } int intNfeature = arrEst.Length; double[,] adblValues = new double[intNfeature, 3]; System.Web.UI.DataVisualization.Charting.Chart pChart = new System.Web.UI.DataVisualization.Charting.Chart(); double dblConfidenceValue = Convert.ToDouble(nudConfidenceLevel.Value); double dblConInstance = pChart.DataManipulator.Statistics.InverseNormalDistribution(dblConfidenceValue / 100); for (int i = 0; i < intNfeature; i++) { double dblValue = arrEst[i]; double dblUncern = dblConInstance * arrVar[i]; if (dblValue < dblUncern) { adblValues[i, 0] = 0; adblValues[i, 1] = dblValue; adblValues[i, 2] = dblUncern; } else { adblValues[i, 0] = dblValue - dblUncern; adblValues[i, 1] = dblUncern; adblValues[i, 2] = dblUncern; } } AddStackedColumnSeries(this, "Low", Color.White, adblValues, 0, intNfeature); AddStackedColumnSeries(this, "Mean", Color.Gray, adblValues, 1, intNfeature); AddStackedColumnSeries(this, "High", Color.Gray, adblValues, 2, intNfeature); double dblMin = 0; double dblMax = arrEst.Max(); for (int j = 1; j < cbIdx.Length - 1; j++) { AddVerticalLineSeries(this, "ver_" + j.ToString(), Color.Red, cbIdx[j] + 0.5, dblMin, dblMax); } } catch (Exception ex) { MessageBox.Show(this.Handle.ToString() + " Error:" + ex.Message); return; } }
private void llena_movimientos_grafico(string tipo, System.Web.UI.DataVisualization.Charting.Chart grafico, int[] barras, string[] nombres) { String queryString = "consulta_movimentos_semanales"; using (MySqlConnection conn = new MySqlConnection(SMysql)) { try { conn.Open(); DataSet ds = new DataSet(); MySqlCommand command = new MySqlCommand(queryString, conn); command.CommandType = CommandType.StoredProcedure; SqlParameter param = new SqlParameter(); // Parámetros command.Parameters.AddWithValue("@v_tipo", tipo); command.Parameters["@v_tipo"].Direction = ParameterDirection.Input; MySqlDataAdapter mysqlDAdp = new MySqlDataAdapter(command); MySqlDataReader dr = command.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { barras[cont] = Convert.ToInt32(dr.GetString(0)); nombres[cont] = dr.GetString(1); //) cont++; } } conn.Close(); conn.Dispose(); // LLenamos el Grafico grafico.Series["Series"].Points.DataBindXY(nombres, barras); grafico.ChartAreas["ChartArea"].AxisX.MajorGrid.Enabled = false; grafico.ChartAreas["ChartArea"].AxisY.MajorGrid.Enabled = false; } catch (Exception ex) { lbl_error.Text = ex.Message; conn.Close(); conn.Dispose(); } } }
protected void getAllSessions() { SQL_utils sql = new SQL_utils(); DataTable dt_all_sessions = sql.DataTable_from_SQLstring("select * from vwPATH_Action_Dates"); System.Web.UI.DataVisualization.Charting.Chart cA = utilMSCharts.MSGeom("point", dt_all_sessions, "ID", "weeks_from_PreT1A", "Action_ActionText", "text", "numeric", "chartname", "All Session Dates", "ID", "weeks_from_PreT1A", -999, -999, -999, -999, 1500, 1100, "mytooltip"); panelCharts.Controls.Add(cA); sql.Close(); }
protected void getTimepointSubj() { SQL_utils sql = new SQL_utils(); DataTable dt = sql.DataTable_from_SQLstring("select * from vwPATH_session_dates_WIDE order by txgrp, daysT1T2 DESC, ID"); DataTable dt_avg = sql.DataTable_from_SQLstring("select * from vwPATH_session_dates_WIDE_AVG"); DataTable dtA = sql.DataTable_from_SQLstring("select * from vwPATH_session_dates where txgrp = 'A'"); DataTable dtB = sql.DataTable_from_SQLstring("select * from vwPATH_session_dates where txgrp = 'B'"); //see this for why it wasn't working in production: //http://stackoverflow.com/questions/7933830/asp-net-charting-control-not-working-on-production-server //I set the ChartImageHandler value in ISS to: //storage=memory;timeout=20;deleteAfterServicing=true; System.Web.UI.DataVisualization.Charting.Chart cA = utilMSCharts.MSGeom("point", dtA, "date", "rankID", "id_subjstatus", "date", "numeric", "chartname", "PATH Dates: group A", "Date", "PATH ID", -999, -999, -999, -999, 1000, 1000, "mytooltip"); panelCharts.Controls.Add(cA); System.Web.UI.DataVisualization.Charting.Chart cB = utilMSCharts.MSGeom("point", dtB, "date", "rankID", "id_subjstatus", "date", "numeric", "chartname", "PATH Dates: group B", "Date", "PATH ID", -999, -999, -999, -999, 1000, 1000, "mytooltip"); ogrid.DataSource = dt; ogrid.DataBind(); panelCharts.Controls.Add(cB); GridView gv = new GridView(); gv.DataSource = dt_avg; gv.DataBind(); gv.Font.Size = 12; panel1.Controls.Add(gv); sql.Close(); }
public ActionResult CrashProbabilityChart(int id) { var chart = new System.Web.UI.DataVisualization.Charting.Chart(); var crashes = chart.Series.Add("Occurrences"); crashes.ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line; ExceptionGroupRepository exceptionGroupRepository = new ExceptionGroupRepository(); foreach (var pair in exceptionGroupRepository.GetCrashStatisticsForExceptionGroup(id)) { crashes.Points.AddXY(pair.Item1, pair.Item2); } chart.Width = 800; chart.Height = 300; chart.RenderType = System.Web.UI.DataVisualization.Charting.RenderType.ImageTag; chart.ChartAreas.Add("Series 1").AxisX.Interval = 1; using (var ms = new MemoryStream()) { chart.SaveImage(ms, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png); ms.Position = 0; return File(ms.ToArray(), "image/png", "mychart.png"); } }
public static void SaveIntHxCharts(SQL_utils sql, int studyID, string id, string path, string periodtype, int ymax) { DataSet ds = Get_MIND_IntHx_v2_Data_by_ID(sql, studyID, id, periodtype); string chartname = "chartname" + id; //int ymax = 80; string filenamebase = "ih" + studyID.ToString().ToLower() + id.ToLower() + periodtype; //Define the x axis min and max, so all the vertlines will fit DateTime?first = null; DateTime?last = null; try { first = ds.Tables["dt_admindates"].AsEnumerable() .Min(r => r.Field <DateTime>("tpdatebeg_SUN")); last = ds.Tables["dt_admindates"].AsEnumerable() .Max(r => r.Field <DateTime>("next_tpdatebeg_SUN")); if (first != null & last != null) { TimeSpan padding = new TimeSpan(14, 0, 0, 0); first = first - padding; last = last + padding; } else { first = null; last = null; } } catch (Exception) { } if (ds != null) { // BY WEEK //DataTable dt_sorted0 = utilMSCharts.Sort(ds.Tables[0], //"wkdatebeg", "txtype"); System.Web.UI.DataVisualization.Charting.Chart c0 = utilMSCharts.MSStackedColumn(ds.Tables[0], "wkdatebeg", "ihhrsperwk", "txtype", "date", ds.Tables["dt_colors0"], chartname, id + ": Week by TYPE(" + periodtype + ")", "Treatment Date", "Hrs per week", -999, -999, -999, ymax, 950, 400, first, last); if (c0 != null) { c0 = utilMSCharts.AddVertLines(c0, ds.Tables["dt_admindates"], "tpdatebeg_SUN", "period_age", "date", -999, -999, -999, ymax); string f0 = filenamebase + "_type_wk.png"; c0.SaveImage(path + f0); } //DataTable dt_sorted1 = utilMSCharts.Sort(ds.Tables[1], //"wkdatebeg", "txcat"); System.Web.UI.DataVisualization.Charting.Chart c1 = utilMSCharts.MSStackedColumn(ds.Tables[1], "wkdatebeg", "ihhrsperwk", "txcat", "date", ds.Tables["dt_colors1"], chartname, id + ": Week by CATEGORY(" + periodtype + ")", "Treatment Date", "Hrs per week", -999, -999, -999, ymax, 800, 400); if (c1 != null) { c1 = utilMSCharts.AddVertLines(c1, ds.Tables["dt_admindates"], "tpdatebeg_SUN", "period_age", "date", -999, -999, -999, ymax); string f1 = filenamebase + "_cat_wk.png"; c1.SaveImage(path + f1); } //DataTable dt_sorted2 = utilMSCharts.Sort(ds.Tables[2], "wkdatebeg", "txall"); System.Web.UI.DataVisualization.Charting.Chart c2 = utilMSCharts.MSStackedColumn(ds.Tables[2], "wkdatebeg", "ihhrsperwk", "txall", "date", ds.Tables["dt_colors2"], chartname, id + ": Week by ALL (" + periodtype + ")", "Treatment Date", "Hrs per week", -999, -999, -999, ymax, 800, 400); if (c2 != null) { c2 = utilMSCharts.AddVertLines(c2, ds.Tables["dt_admindates"], "tpdatebeg_SUN", "period_age", "date", -999, -999, -999, ymax); string f2 = filenamebase + "_all_wk.png"; c2.SaveImage(path + f2); } bool byperiod = false; if (byperiod) { // BY PERIOD System.Web.UI.DataVisualization.Charting.Chart c3 = utilMSCharts.MSStackedColumn(utilMSCharts.Sort(ds.Tables[3], "period", "txtype"), "period", "avgPER_ihhrsperwk", "txtype", "string", ds.Tables["dt_colors0"], ds.Tables[3].TableName + " " + id, id + ": " + periodtype + " by TYPE", "Period", "Avg Hrs/wk during period", -999, -999, -999, ymax, 400, 400); if (c3 != null) { string f3 = filenamebase + "_type_period.png"; c3.SaveImage(path + f3); } System.Web.UI.DataVisualization.Charting.Chart c4 = utilMSCharts.MSStackedColumn(utilMSCharts.Sort(ds.Tables[4], "period", "txcat"), "period", "avgPER_ihhrsperwk", "txcat", "string", ds.Tables["dt_colors1"], ds.Tables[4].TableName + " " + id, id + ": " + periodtype + " by CATEGORY", "Period", "Avg Hrs/wk during period", -999, -999, -999, ymax, 400, 400); if (c4 != null) { string f4 = filenamebase + "_cat_period.png"; c4.SaveImage(path + f4); } System.Web.UI.DataVisualization.Charting.Chart c5 = utilMSCharts.MSStackedColumn(utilMSCharts.Sort(ds.Tables[5], "period", "txall"), "period", "avgPER_ihhrsperwk", "txall", "string", ds.Tables["dt_colors2"], ds.Tables[5].TableName + " " + id, id + ": " + periodtype + " by ALL", "Period", "Avg Hrs/wk during period", -999, -999, -999, ymax, 400, 400); if (c5 != null) { string f5 = filenamebase + "_all_period.png"; c5.SaveImage(path + f5); } // BY PERIOD - ACTIVE System.Web.UI.DataVisualization.Charting.Chart c3act = utilMSCharts.MSStackedColumn(utilMSCharts.Sort(ds.Tables[3], "period", "txtype"), "period", "avgACT_ihhrsperwk", "txtype", "string", ds.Tables["dt_colors0"], ds.Tables[3].TableName + " " + id, id + ": " + periodtype + " by TYPE *ACTIVE*", "Period", "Avg Hrs/wk during period ACTIVE", -999, -999, -999, ymax, 400, 400); if (c3act != null) { string f3act = filenamebase + "_type_periodACTIVE.png"; c3act.SaveImage(path + f3act); } System.Web.UI.DataVisualization.Charting.Chart c4act = utilMSCharts.MSStackedColumn(utilMSCharts.Sort(ds.Tables[4], "period", "txcat"), "period", "avgACT_ihhrsperwk", "txcat", "string", ds.Tables["dt_colors1"], ds.Tables[4].TableName + " " + id, id + ": " + periodtype + " by CATEGORY *ACTIVE*", "Period", "Avg Hrs/wk during period ACTIVE", -999, -999, -999, ymax, 400, 400); if (c4act != null) { string f4act = filenamebase + "_cat_periodACTIVE.png"; c4act.SaveImage(path + f4act); } System.Web.UI.DataVisualization.Charting.Chart c5act = utilMSCharts.MSStackedColumn(utilMSCharts.Sort(ds.Tables[5], "period", "txall"), "period", "avgACT_ihhrsperwk", "txall", "string", ds.Tables["dt_colors2"], ds.Tables[5].TableName + " " + id, id + ": " + periodtype + " by ALL *ACTIVE*", "Period", "Avg Hrs/wk during period ACTIVE", -999, -999, -999, ymax, 400, 400); if (c5act != null) { string f5act = filenamebase + "_all_periodACTIVE.png"; c5act.SaveImage(path + f5act); } } } //Debug.WriteLine(id); //sql.Close(); }