public DxBarchart(DxChartSettings settings, DescStats mystats) //, string xvar, string yvar, string titleinput, string colorsby) { _settings = settings; //Color col = _settings.color(0); CreateBarchart(mystats); }
//public DxBarchart(DataTable mydt, string xvar, string yvar, string titleinput, Color mycolor, string colorsby) //{ // _settings.xaxisvar = xvar; // _settings.yaxisvar = yvar; // _settings.title = titleinput; // _settings.colorvar = colorsby; // Color col = _settings.color(0); //} public void CreateBarchart(DataTable mydt) //, string xvar, string yvar, string mytitle, Color mycolor, string colorsby) { List <string> grouping_vars = new List <string>(); grouping_vars.Add(_settings.xaxisvar); grouping_vars.Add(_settings.colorvar); if (_settings.panelvar != null & _settings.panelvar != "variable") { grouping_vars.Add(_settings.panelvar); } grouping_vars.RemoveAll(item => item == "variable"); grouping_vars.RemoveAll(item => item == "none"); _statstable = (grouping_vars.Count > 0) ? new DescStats(mydt, _settings.numvars, grouping_vars) : new DescStats(mydt, _settings.numvars); if (_settings.panelvar == "variable") { grouping_vars.Add(_settings.panelvar); } CreateBarchart(_statstable); if (_statstable.dt.Rows.Count == 0) { this.isempty = true; this.emptymsg = _statstable.emptystats; } }
//Barchart //need to get stats first! public DxChartBatch(DxBarchartSettings mysettings, DataTable dt) { Initialize(); _batchsettings = (DxChartSettings)mysettings; outputtype = DxOutputtype.Barchart; layout = mysettings.chartlayout; _vars = mysettings.numvars; if (mysettings.agevars != null) { _vars.AddRange(mysettings.agevars); } mysettings.numvars.Remove("id"); if (mysettings.panelvar == "none") { DxBarchart chart = new DxBarchart(mysettings, dt); charts.Add(chart); _datatables.Add(chart.statstable.dt); } else { List <string> grpvarnames = new List <string>(); grpvarnames.Add(mysettings.xaxisvar); grpvarnames.Add(mysettings.colorvar); grpvarnames.Add(mysettings.panelvar); grpvarnames.RemoveAll(item => item == "variable"); grpvarnames.RemoveAll(item => item == "none"); DescStats stats = new DescStats(dt, _vars, grpvarnames); DxBarchart chart = new DxBarchart(mysettings, stats); //chart.AddTitles(subset.Cols_and_Vals_ToString()); charts.Add(chart); //fix? //_datatables.Add(chart.statstable.dt); } }
public void CreateBarchart(DescStats statstable) //, string xaxisvar, string colorsvar, string maintitle ) { chart.AxisWholeRangeChanged += LogAxesRangeWhole; //chart.AxisVisualRangeChanged += LogAxesRangeVisual; string mycolorvar; if (_settings.colorvar == "none") { mycolorvar = (statstable.dt.ColumnNames().Contains("All")) ? "All" : _settings.xaxisvar; } else { mycolorvar = _settings.colorvar; } List <string> colors_levels = statstable.dt.AsEnumerable().Select(x => x.Field <string>(mycolorvar)).Distinct().ToList(); List <string> xaxis_levels = statstable.dt.AsEnumerable().Select(x => x.Field <string>(_settings.xaxisvar)).Distinct().ToList(); List <string> panes_levels = new List <string>(); if (_settings.panelvar != "none") { panes_levels = statstable.dt.AsEnumerable().Select(x => x.Field <string>(_settings.panelvar)).Distinct().ToList(); panes_levels.Sort(); } //for (int i = 0; i < colors_levels.Count; i++) //{ // string current_color_lev = colors_levels[i]; //} foreach (Series ser in chart.Series) { Debug.WriteLine(String.Format("arg data member:[{0}] color data member:[{1}]", ser.ArgumentDataMember, ser.ColorDataMember)); } BarchartSeries barseries = new BarchartSeries(statstable.dt, _settings.xaxisvar, _settings.colorvar, _settings.panelvar, _settings.colors, colors_levels); foreach (DxSeriesPoints sp in barseries.list_dxseriespoints) { Series s = new Series(); s.Points.AddRange(sp.seriesPoints); SideBySideBarSeriesView vw = new SideBySideBarSeriesView(); s.View = vw; var thesd = sp.seriesPointsSD[0].Values[0]; vw.Indicators.Add(new FixedValueErrorBars { Direction = ErrorBarDirection.Both, Name = "SD", Color = Color.Black, PositiveError = thesd, NegativeError = thesd }); chart.Series.Add(s); } Debug.WriteLine(String.Format("***************************** INIT # of Panes: {0}", xydiagram.Panes.Count)); //Additional Panes if (panes_levels.Count > 0) { xydiagram.Panes.Clear(); Debug.WriteLine(String.Format("***************************** After CLEAR # of Panes: {0}", xydiagram.Panes.Count)); foreach (string p in panes_levels) { // Obtain a diagram and clear its collection of panes. XYDiagramPane pane = new XYDiagramPane(p); xydiagram.Panes.Add(pane); pane.Title.Text = p; pane.Title.Visibility = DefaultBoolean.True; xydiagram.PaneLayout.Direction = _settings.panesLayoutDirection; // PaneLayoutDirection.Horizontal; Debug.WriteLine(String.Format("********************************** # of Panes: {0} {1}", xydiagram.Panes.Count, p)); // check whether series should be added to this pane. for (int i = 0; i < chart.Series.Count; i++) { // if (sps[i].panename == p) if (barseries.list_dxseriespoints[i].panename == p) { XYDiagramSeriesViewBase view = (XYDiagramSeriesViewBase)chart.Series[i].View; view.Pane = xydiagram.Panes[p]; } } xydiagram.DefaultPane.Visibility = ChartElementVisibility.Hidden; } } //No Additional Panes else { for (int i = 0; i < chart.Series.Count; i++) { XYDiagramSeriesViewBase view = (XYDiagramSeriesViewBase)chart.Series[i].View; view.Pane = xydiagram.DefaultPane; } } chart.DataBind(); //Adjust axis range if needed if (_settings.miny != -999 && _settings.maxy != -999) { double y1 = _settings.miny; double y2 = _settings.maxy; //diag.AxisY.VisualRange.SetMinMaxValues(y1, y2); xydiagram.AxisY.WholeRange.SetMinMaxValues(y1, y2); xydiagram.AxisY.VisualRange.SetMinMaxValues(y1, y2); } chart.Width = _settings.W; chart.Height = _settings.H; #region Titles if (_settings.numvars.Count == 1) { AddTitles(_settings.title, _settings.subtitle, "", String.Format("{0} Mean (SD)", _settings.numvars[0])); } else { AddTitles(_settings.title, _settings.subtitle, "", "Mean (SD)"); } #endregion chart.BorderOptions.Color = Color.White; this.LegendByColorLevels(_settings.colors, colors_levels); chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True; }