Exemplo n.º 1
0
        public static Table HorizontalTable(DxChartBatch batch, string obj)
        {
            Table t = new Table();

            int numrow  = (int)(batch.charts.Count / batch.maxCol) + 1;
            int counter = 0;

            for (int i = 0; i < numrow; i++)
            {
                TableRow r = new TableRow();
                for (int j = 0; j < batch.maxCol; j++)
                {
                    TableCell c       = new TableCell();
                    bool      addcell = true;
                    if (counter < batch.charts.Count)
                    {
                        int newW = Convert.ToInt32(batch.charts[counter].W);
                        int newH = Convert.ToInt32(batch.charts[counter].H);

                        DxChart thisdxchart = batch.charts[counter];
                        if (thisdxchart.chart == null | thisdxchart.chart.Series.Count == 0)
                        {
                            addcell = !batch.batchsettings.hideEmptyCharts;
                            //if we want to hideEmptyCharts (=T, that is Not Show It) then we don't want to add the cell.
                            //if we don't want to hideEmptyCharts (=F, that is Show It) then we do want to add the cell.
                            string thisdxchart_info = String.Format("# series={0}   # vars={1}   emptymsg={2} "
                                                                    , thisdxchart.chart.Series.Count, batch.batchsettings.numvars.Count, thisdxchart.emptymsg);

                            PlaceTextInCell(c, thisdxchart_info);
                        }
                        else
                        {
                            if (obj == "chart")
                            {
                                PlaceChartInCell(batch.charts[counter], c, newW, newH);
                            }
                            else if (obj == "datatable")
                            {
                                PlaceTableInCell(batch.datatables[counter], c);
                            }
                            counter++;
                        }
                    }
                    if (addcell)
                    {
                        r.Cells.Add(c);
                    }
                }
                t.Rows.Add(r);
            }

            return(t);
        }
Exemplo n.º 2
0
        public static Table VerticalTable(DxChartBatch batch)
        {
            Table t = new Table();

            double dbl_numcol = batch.charts.Count / (batch.maxRow * 1.0);

            if (dbl_numcol > 0)
            {
                int numcol = Convert.ToInt32(Math.Ceiling(dbl_numcol));

                int counter = 0;

                for (int i = 0; i < batch.maxRow; i++)
                {
                    TableRow r = new TableRow();
                    for (int j = 0; j < numcol; j++)
                    {
                        TableCell c       = new TableCell();
                        bool      addcell = true;
                        int       idx     = i + (j * batch.maxRow);
                        if (idx < batch.charts.Count)
                        {
                            int newW = Convert.ToInt32(batch.charts[idx].W);
                            int newH = Convert.ToInt32(batch.charts[idx].H);

                            if (batch.charts[idx].chart == null | batch.charts[idx].chart.Series.Count == 0)
                            {
                                //do nothing, the missing chart and emptymsg is not displayed
                                addcell = false;
                            }
                            else
                            {
                                PlaceChartInCell(batch.charts[idx], c, newW, newH);
                            }
                            counter++;
                        }
                        if (addcell)
                        {
                            r.Cells.Add(c);
                        }
                    }
                    t.Rows.Add(r);
                }

                return(t);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
 public void PrepareBatch(DxChartBatch batch, DxChartSettings settings)
 {
     if (batch.charts.Count > 0)
     {
         batch.maxCol = settings.maxCol;
         batch.maxRow = settings.maxRow;
         batch.layout = settings.chartlayout;
         foreach (DxChart chart in batch.charts)
         {
             chart.W = settings.W;
             chart.H = settings.H;
         }
     }
 }
Exemplo n.º 4
0
        public static Table UpperTable(DxChartBatch batch)
        {
            Table t = new Table();

            int counter = 0;
            int ncols   = NCols(batch.charts.Count);

            //TableRow headerrow = CreateHeaderRow(title, ncols);
            //t.Rows.Add(headerrow);
            t.Rows.Add(CreateHeaderRow(batch.vars, ncols));


            for (int rows = 0; rows < ncols; rows++)
            {
                TableRow r = new TableRow();
                //add the first column

                TableCell c0 = new TableCell();
                PlaceTextInCell(c0, batch.vars[rows], true, 12, Color.Gray);
                r.Cells.Add(c0);


                for (int cols = 0; cols < ncols; cols++)
                {
                    TableCell c = new TableCell();
                    if (cols == rows)
                    {
                        //if(hasAlternateDiag)
                        //{
                        //	PlaceChartInCell(charts[chartnum], c, W, H, pct);
                        //	chartnum++;
                        //}
                    }
                    else if (cols > rows)
                    {
                        PlaceChartInCell(batch.charts[counter], c, batch.charts[counter].W, batch.charts[counter].H, 1.0);
                        counter++;
                    }
                    r.Cells.Add(c);
                }
                t.Rows.Add(r);
            }

            return(t);
        }
Exemplo n.º 5
0
        public static Table LayoutBatch(DxChartBatch batch, string obj)
        {
            if (obj == "datatable")
            {
                Table t = new Table();
                if (batch.layout == DxLayout.Horizontal)
                {
                    t = HorizontalTable(batch, obj);
                }
                //else if (batch.chartlayout == DxChartLayout.Vertical) t = VerticalTable(batch);
                //else if (batch.chartlayout == DxChartLayout.Upper) return UpperTable(batch);
                //else if (batch.chartlayout == DxChartLayout.UpperDiag) return UpperDiagTable(batch);

                return(t);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
        //public ChartOutput()
        //{
        //	//
        //	// TODO: Add constructor logic here
        //	//
        //}

        public static Table LayoutBatch(DxChartBatch batch)
        {
            Table t = new Table();

            if (batch.layout == DxLayout.Horizontal)
            {
                t = HorizontalTable(batch);
            }
            else if (batch.layout == DxLayout.Vertical)
            {
                t = VerticalTable(batch);
            }
            else if (batch.layout == DxLayout.Upper)
            {
                return(UpperTable(batch));
            }
            else if (batch.layout == DxLayout.UpperDiag)
            {
                return(UpperDiagTable(batch));
            }

            return(t);
        }
Exemplo n.º 7
0
 public static Table HorizontalTable(DxChartBatch batch)
 {
     return(HorizontalTable(batch, "chart"));
 }
Exemplo n.º 8
0
        public void ProcessOrder(DxChartOrder order)
        {
            if (order.isOrderFilled)             //Already have batches
            {
                order.batches.Clear();
            }

            //Skip the_dpdata stuff if _dt is already populated
            if (_dt == null)
            {
                bool hassameworksheet = order.HasSameWorksheet(_dpdata);

                if (!hassameworksheet)
                {
                    //Need new DPData
                    _dataproject.selectedsheet = order.worksheet;
                    _dpdata = new DPData(_dataproject, order.filter);
                }


                bool hassamefilter = order.HasSameFilter(_dpdata);

                if (!hassamefilter)
                {
                    _dpdata.filter = order.filter;
                }

                _dt = _dpdata.dt;
            }

            //Each order will result in a list of batches
            //List<DxBatchOcharts> batchlist = new List<DxBatchOcharts>();
            List <DxChartBatch> batchlist = new List <DxChartBatch>();

            if (order.list_settings != null)
            {
                foreach (DxChartSettings settings in order.list_settings)
                {
                    #region Histogram
                    if (settings.outputtype == DxOutputtype.Histogram)
                    {
                        DxHistogramSettings mysettings = (DxHistogramSettings)settings;
                        DxChartBatch        batch      = new DxChartBatch(mysettings, dt);
                        PrepareBatch(batch, settings);
                        batchlist.Add(batch);
                    }
                    #endregion

                    #region Barchart
                    else if (settings.outputtype == DxOutputtype.Barchart)
                    {
                        DxBarchartSettings mysettings = (DxBarchartSettings)settings;
                        DxChartBatch       batch      = new DxChartBatch(mysettings, dt);
                        PrepareBatch(batch, settings);
                        batchlist.Add(batch);
                    }
                    #endregion

                    #region Scatterplot
                    else if (settings.outputtype == DxOutputtype.Scatterplot)
                    {
                        DxScatterplotSettings mysettings = (DxScatterplotSettings)settings;

                        if (mysettings.repeatedmeasVarname == "none")
                        {
                            //DxChartBatch batch = new DxChartBatch(mysettings, dt);
                            //PrepareBatch(batch, settings);
                            //batchlist.Add(batch);

                            foreach (XYpairType mode in mysettings.xypairtypes)
                            {
                                if (mode == XYpairType.AllVars_IgnoreLevelsOfRptMeas)
                                {
                                    mysettings.current_xypairtype = mode;
                                    //mysettings.maxCol = ncol1;
                                    //mysettings.maxRow = tmpvars.Count;
                                    mysettings.chartlayout         = DxLayout.Horizontal;
                                    mysettings.repeatedmeasVarname = "none";

                                    DxChartBatch batch1 = new DxChartBatch(mysettings, dt);
                                    PrepareBatch(batch1, (DxChartSettings)mysettings);
                                    batch1.batchtitle = String.Format("All variables (IGNORE Time/RptMeas)");
                                    batch1.maxCol     = batch1.charts.Count;
                                    batchlist.Add(batch1);
                                }
                            }
                        }
                        else if (mysettings.repeatedmeasVarname != "none")
                        {
                            List <string> repeatedmeas_levels = dt.AsEnumerable().Select(f => f.Field <string>(mysettings.repeatedmeasVarname)).Distinct().ToList();

                            List <string> analysisvars = new List <string>();
                            analysisvars.AddRange(mysettings.numvars);
                            if (mysettings.agevars != null)
                            {
                                analysisvars.AddRange(mysettings.agevars);
                            }

                            int n_rptmeas      = repeatedmeas_levels.Count;
                            int n_analysisvars = analysisvars.Count;

                            int ncol1 = utilStats.TriangleNumber(n_rptmeas);


                            List <string> tmpvars  = mysettings.analysisvars();
                            List <string> tmpvarsX = mysettings.analysisvarsX();
                            List <string> tmpvarsY = mysettings.analysisvarsY();


                            #region Process By Mode
                            foreach (XYpairType mode in mysettings.xypairtypes)
                            {
                                if (mode == XYpairType.AllVars_IgnoreLevelsOfRptMeas)
                                {
                                    mysettings.current_xypairtype = mode;
                                    //mysettings.maxCol = ncol1;
                                    //mysettings.maxRow = tmpvars.Count;
                                    mysettings.chartlayout         = DxLayout.Horizontal;
                                    mysettings.repeatedmeasVarname = "none";

                                    DxChartBatch batch1 = new DxChartBatch(mysettings, dt);
                                    PrepareBatch(batch1, (DxChartSettings)mysettings);
                                    batch1.batchtitle = String.Format("All variables (IGNORE Time/RptMeas)");
                                    batch1.maxCol     = batch1.charts.Count;
                                    batchlist.Add(batch1);
                                }

                                if (mode == XYpairType.SameVar_AcrossLevelsOfRptMeas)
                                {
                                    mysettings.current_xypairtype = mode;
                                    mysettings.maxCol             = ncol1;
                                    //mysettings.maxRow = tmpvars.Count;
                                    mysettings.chartlayout = DxLayout.Horizontal;

                                    //Loop over vars, make a batch for each one
                                    foreach (string v in tmpvars)
                                    {
                                        mysettings.manualXandYvars = true;
                                        mysettings.xvars           = new List <string> {
                                            v
                                        };
                                        mysettings.yvars = new List <string> {
                                            v
                                        };
                                        DxChartBatch batch1 = new DxChartBatch(mysettings, dt);
                                        PrepareBatch(batch1, (DxChartSettings)mysettings);
                                        batch1.batchtitle = String.Format("{0} ACROSS levels of {1}", v, mysettings.repeatedmeasVarname);
                                        batch1.maxCol     = batch1.charts.Count;
                                        batchlist.Add(batch1);
                                    }
                                }

                                if (mode == XYpairType.DiffVar_WithinLevelsOfRptMeas)
                                {
                                    //#2 - treat it as square
                                    mysettings.current_xypairtype = mode;
                                    //mysettings.numvars = tmpvars;
                                    mysettings.xvars = null;
                                    mysettings.yvars = null;

                                    mysettings.chartlayout = DxLayout.Upper;
                                    mysettings.maxRow      = tmpvars.Count;

                                    List <string> rptmeasLevels = dt.AsEnumerable().Select(f => f.Field <string>(mysettings.repeatedmeasVarname)).Distinct().ToList();

                                    List <string> tmpvars_with_id = new List <string>();
                                    tmpvars_with_id.AddRange(tmpvars);
                                    tmpvars_with_id.Add("id");

                                    DataSubsets dt_rptmeas = new DataSubsets(dt, tmpvars_with_id, mysettings.repeatedmeasVarname);

                                    //Loop across levels of the RptMeas
                                    foreach (DataSubset subset in dt_rptmeas.subsets)
                                    {
                                        DxChartBatch batch2 = new DxChartBatch(mysettings, subset.dt);
                                        PrepareBatch(batch2, (DxChartSettings)mysettings);
                                        batch2.batchtitle = String.Format("Variables WITHIN {0}: {1}", mysettings.repeatedmeasVarname, subset.Vals_ToString());
                                        batch2.maxCol     = batch2.charts.Count;
                                        batchlist.Add(batch2);
                                    }
                                }

                                if (mode == XYpairType.DiffVar_AcrossLevelsOfRptMeas)
                                {
                                    //#2 - back to original
                                    mysettings.current_xypairtype = mode;
                                    //mysettings.numvars = tmpvars;
                                    mysettings.xvars           = tmpvarsX;
                                    mysettings.yvars           = tmpvarsY;
                                    mysettings.manualXandYvars = true;
                                    mysettings.chartlayout     = DxLayout.Horizontal;

                                    List <string> rptmeasLevels = dt.AsEnumerable().Select(f => f.Field <string>(mysettings.repeatedmeasVarname))
                                                                  .Distinct().ToList();
                                    //HERE!!!!

                                    for (int i = 0; i < (rptmeasLevels.Count - 1); i++)
                                    {
                                        for (int j = i + 1; j < rptmeasLevels.Count; j++)
                                        {
                                            DataView dv = new DataView(dt);                                             // dt.AsDataView();
                                            dv.RowFilter = String.Format("{0} IN ('{1}','{2}')", mysettings.repeatedmeasVarname, rptmeasLevels[i], rptmeasLevels[j]);
                                            DataTable dt_sub = dv.ToTable();

                                            if (dt_sub.Rows.Count > 1)
                                            {
                                                DxChartBatch batch3 = new DxChartBatch(mysettings, dt_sub);
                                                PrepareBatch(batch3, (DxChartSettings)mysettings);
                                                batch3.batchtitle = String.Format("Variables ACROSS {0}:{1} & {2}", mysettings.repeatedmeasVarname, rptmeasLevels[i], rptmeasLevels[j]);
                                                batch3.maxCol     = batch3.charts.Count;
                                                batchlist.Add(batch3);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                    #endregion

                    #region Actogram
                    else if (settings.outputtype == DxOutputtype.Actogram)
                    {
                        DxActogramSettings mysettings = (DxActogramSettings)settings;
                        mysettings.outputtype = DxOutputtype.Actogram;

                        List <string> varnames = new List <string>()
                        {
                            "id"
                        };
                        varnames.AddRange(mysettings.numvars);
                        varnames.Add(mysettings.xaxisvar);
                        varnames.Add(mysettings.colorvar);
                        varnames.RemoveAll(item => item == "variable");
                        varnames.RemoveAll(item => item == "none");


                        DataSubsets subsets = new DataSubsets(dt, varnames, new List <string> {
                            mysettings.panelvar
                        });

                        DxChartBatch batch2 = new DxChartBatch(DxOutputtype.Actogram, mysettings);

                        foreach (DataSubset subset in subsets.subsets)
                        {
                            mysettings.date_txt = subset.dt.AsEnumerable().Min(f => f.Field <string>("report_date"));

                            DxChartBatch subbatch = new DxChartBatch(mysettings, subset.dt, subset.Cols_and_Vals_ToString());

                            foreach (DxChart sub in subbatch.charts)
                            {
                                batch2.charts.Add(sub);
                            }
                        }
                        PrepareBatch(batch2, mysettings);
                        batchlist.Add(batch2);
                    }
                    #endregion

                    #region Lineplot
                    else if (settings.outputtype == DxOutputtype.Lineplot)
                    {
                        DxLineplotSettings mysettings = (DxLineplotSettings)settings;

                        //NO Panels
                        if (mysettings.panelvar == "none" | mysettings.panelvar == "variable")
                        {
                            DxChartBatch batch1 = new DxChartBatch(mysettings, dt, " ");
                            PrepareBatch(batch1, settings);
                            batchlist.Add(batch1);
                        }
                        else
                        {
                            List <string> varnames = new List <string>()
                            {
                                "id"
                            };
                            varnames.AddRange(mysettings.numvars);
                            varnames.Add(mysettings.xaxisvar);
                            varnames.Add(mysettings.colorvar);
                            varnames.RemoveAll(item => item == "variable");
                            varnames.RemoveAll(item => item == "none");


                            DataSubsets subsets = new DataSubsets(dt, varnames, new List <string> {
                                mysettings.panelvar
                            });

                            DxChartBatch batch2 = new DxChartBatch(DxOutputtype.Lineplot, mysettings);
                            batch2.vars = mysettings.numvars;
                            foreach (DataSubset subset in subsets.subsets)
                            {
                                DxChartBatch subbatch = new DxChartBatch(mysettings, subset.dt, subset.Cols_and_Vals_ToString());

                                foreach (DxChart sub in subbatch.charts)
                                {
                                    batch2.charts.Add(sub);
                                }
                            }
                            PrepareBatch(batch2, mysettings);
                            batchlist.Add(batch2);
                        }
                    }
                    #endregion
                }
            }

            order.batches.AddRange(batchlist);

            //The invoice serves as a table of contents for what was actually created
            order.PrepareInvoice();
        }