예제 #1
0
        private void SetMainView(IEnumerable <ResultItem> dt, string queryType)
        {
            bool isNewWindow = this.newWindowCheckBox.Checked;
            int  panelCount  = this._mainView.DockManager.Panels.Count;

            PivotGridControl pivotGridControl = new PivotGridControl();

            pivotGridControl.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PivotGridControl_MouseClick);

            ChartControl chartControl = new ChartControl();

            DockPanel dockPanel = null;

            if (isNewWindow || panelCount == 0)
            {
                dockPanel      = this._mainView.DockManager.AddPanel(DevExpress.XtraBars.Docking.DockingStyle.Float);
                dockPanel.Text = queryType;
                dockPanel.DockedAsTabbedDocument = true;
            }
            else
            {
                dockPanel      = this._mainView.DockManager.Panels[panelCount - 1];
                dockPanel.Text = queryType;
                dockPanel.Controls.Clear();
            }

            SubView subView = new SubView();

            subView.Dock = DockStyle.Fill;

            pivotGridControl.Dock = DockStyle.Fill;
            chartControl.Dock     = DockStyle.Fill;

            subView.SplitContainerControl.Panel1.Controls.Add(pivotGridControl);
            subView.SplitContainerControl.Panel2.Controls.Add(chartControl);

            dockPanel.Controls.Add(subView);

            this.SetPivotGridFields(pivotGridControl);
            this.SetPivotGridData(dt, pivotGridControl);
        }
예제 #2
0
        private void DrawChart(DataTable dtResult, List <string> SelProds)
        {
            DockPanel panel = null;

            if (this._mainView.ActiveControl != null)
            {
                panel = this._mainView.ActiveControl as DockPanel;
            }
            else
            {
                panel = this._mainView.DockManager.ActivePanel;
            }

            SubView         subView    = panel.ActiveControl as SubView;
            SplitGroupPanel chartPanel = subView.SplitContainerControl.Panel2;

            chartPanel.Controls.Clear();

            DataView dv = dtResult.DefaultView;

            dv.Sort  = "DATE";
            dtResult = dv.ToTable();

            ChartControl chart = new ChartControl();

            chart.Dock = DockStyle.Fill;
            chartPanel.Controls.Add(chart);

            Series moveSeries   = new Series("MOVE", ViewType.Line);
            Series targetSeries = new Series("TARGET", ViewType.Line);

            moveSeries.LabelsVisibility   = DevExpress.Utils.DefaultBoolean.True;
            targetSeries.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;

            (moveSeries.View as LineSeriesView).MarkerVisibility   = DevExpress.Utils.DefaultBoolean.True;
            (targetSeries.View as LineSeriesView).MarkerVisibility = DevExpress.Utils.DefaultBoolean.True;

            chart.Series.Add(moveSeries);
            chart.Series.Add(targetSeries);

            Dictionary <string, List <decimal> > aggregateMappings = new Dictionary <string, List <decimal> >();

            foreach (DataRow row in dtResult.Rows)
            {
                string  prodID = row["PRODUCT_ID"].ToString();
                string  date   = row["DATE"].ToString();
                decimal move   = Convert.ToDecimal(row["MOVE"]);
                decimal target = Convert.ToDecimal(row["TARGET"]);

                if (SelProds.Contains(prodID) == false)
                {
                    continue;
                }

                if (SelProds.Count > 1)
                {
                    var key = date;
                    if (aggregateMappings.ContainsKey(key))
                    {
                        aggregateMappings[key][0] += move;
                        aggregateMappings[key][1] += target;
                    }
                    else
                    {
                        aggregateMappings.Add(key, new List <decimal>()
                        {
                            move, target
                        });
                    }

                    continue;
                }

                SeriesPoint movePoint   = new SeriesPoint(date, move);
                SeriesPoint targetPoint = new SeriesPoint(date, target);

                moveSeries.Points.Add(movePoint);
                targetSeries.Points.Add(targetPoint);
            }

            foreach (var item in aggregateMappings)
            {
                SeriesPoint movePoint   = new SeriesPoint(item.Key, item.Value.ElementAt(0));
                SeriesPoint targetPoint = new SeriesPoint(item.Key, item.Value.ElementAt(1));

                moveSeries.Points.Add(movePoint);
                targetSeries.Points.Add(targetPoint);
            }
        }