public void CreateHistogram(DataTable mydt) { HistBinsData histdata = new HistBinsData(mydt, _settings.xaxisvar, _settings.numbins); if (histdata.N > 0) { Color colortouse = _settings.colors[0]; Series s = CreateHistogramSeries(histdata.bins, colortouse, false); AreaSeriesView vw = (AreaSeriesView)s.View; chart.Series.Add(s); //Normal curve if (_settings.shownormalcurve & histdata.normalX != null) { Series s_nc = CreateNormalCurveSeries(histdata.normalX, histdata.normalY, colortouse, false); PointSeriesView vw_nc = (PointSeriesView)s_nc.View; chart.Series.Add(s_nc); } //M SD if (_settings.histMSD) { Series s_msd = CreateMSDSeries(histdata.mean, histdata.sd, 0, colortouse, false); PointSeriesView vw_msd = (PointSeriesView)s_msd.View; chart.Series.Add(s_msd); } string newline = Environment.NewLine; string subtitle_text = String.Format("<color={0}> N={1} M={2} SD={3}</color>", ColorTranslator.ToHtml(colortouse) , histdata.N , Math.Round(histdata.mean, 2) , Math.Round(histdata.sd, 2)); this.AddTitles(String.Format("Histogram <b>{0}</b>", _settings.xaxisvar), subtitle_text, "", "Count"); chart.Width = _settings.W; chart.Height = _settings.H; chart.BorderOptions.Color = Color.White; chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True; } else { //_emptymsg = String.Format("0 cases for {0} {1}", subtitle, var); //return null; } }
//Given a list of subsets are passed in, these are displayed in a panes public void CreateHistogram_withPanes(List <DataSubset> subsets, string mysubtitle, string var) //, Color mycolor) { List <HistBinsData> list_o_histdata = new List <HistBinsData>(); List <string> subtitle1 = new List <string>(); string panelvar = ""; //Create a series for each subset for (int i = 0; i < subsets.Count; i++) { DataSubset subset = subsets[i]; HistBinsData histdata = new HistBinsData(subset.dt, var, _settings.numbins); if (histdata.N > 0) { if (panelvar == "") { panelvar = subset.Cols_ToString(); } list_o_histdata.Add(histdata); subtitle1.Add(subset.Vals_ToString()); } } //Panes this.AddPanes((list_o_histdata.Count - 1), _settings.panesLayoutDirection); List <string> subtitles = new List <string>(); //Create a series for each subset for (int i = 0; i < list_o_histdata.Count; i++) { HistBinsData histdata = list_o_histdata[i]; if (histdata.N > 0) { Color mypanelcolor = _settings.color(i); Series s = CreateHistogramSeries(histdata.bins, mypanelcolor, false); AreaSeriesView vw = (AreaSeriesView)s.View; if (i >= 1) { vw.Pane = this.xydiagram.Panes[(i - 1)]; //Panes collection starts at index 0, but first series goes into default pane } chart.Series.Add(s); //Normal Curve if (_settings.shownormalcurve & histdata.normalX != null) { Series s_nc = CreateNormalCurveSeries(histdata.normalX, histdata.normalY, mypanelcolor, false); PointSeriesView vw_nc = (PointSeriesView)s_nc.View; if (i >= 1) { vw_nc.Pane = this.xydiagram.Panes[(i - 1)]; } chart.Series.Add(s_nc); } //M SD if (_settings.histMSD) { Series s_msd = CreateMSDSeries(histdata.mean, histdata.sd, 0, mypanelcolor, false); PointSeriesView vw_msd = (PointSeriesView)s_msd.View; if (i >= 1) { vw_msd.Pane = this.xydiagram.Panes[(i - 1)]; } chart.Series.Add(s_msd); } string newline = Environment.NewLine; string subtitle_text = String.Format("<color={0}><b>{1}</b> N={2} M={3} SD={4}</color>{5}", ColorTranslator.ToHtml(mypanelcolor) , subtitle1[i] , histdata.N, Math.Round(histdata.mean, 2), Math.Round(histdata.sd, 2), newline); subtitles.Add(subtitle_text); } } string subtitles_merged = String.Join(" ", subtitles); //this.AddTitles(String.Format("Histogram <b>{0}{1}* by {2} *</b>" // , var // , Environment.NewLine // , panelvar), subtitles_merged, "", "Count"); string maintitle = String.Format("Histogram <b>{0}{1}* by {2} *</b>" , var , Environment.NewLine , panelvar); this.AddTitles(maintitle); XYDiagramDefaultPane defpane = xydiagram.DefaultPane; defpane.Title.Text = subtitles[0]; defpane.Title.Visibility = DefaultBoolean.True; for (int p = 0; p < xydiagram.Panes.Count; p++) { XYDiagramPane pane = xydiagram.Panes[p]; pane.Title.Text = subtitles[p + 1]; } chart.Width = _settings.W; chart.Height = _settings.H; chart.BorderOptions.Color = Color.White; chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True; }