private void PrintHistogram(Dictionary <int, double> pixel, PictureBox pictureBox)
        {
            ZedGraphControl zedGraphControl = new ZedGraphControl();

            zedGraphControl.Dock = DockStyle.Fill;
            zedGraphControl.IsSynchronizeXAxes                  = true;
            zedGraphControl.GraphPane.Title.IsVisible           = false;
            zedGraphControl.GraphPane.XAxis.Title.IsVisible     = false;
            zedGraphControl.GraphPane.YAxis.Title.IsVisible     = false;
            zedGraphControl.GraphPane.XAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsVisible = true;

            PointPairList pointPairList = new PointPairList();

            foreach (int item in pixel.Keys)
            {
                pointPairList.Add(item, pixel[item]);
            }

            GraphPane graphPane = zedGraphControl.GraphPane;
            BarItem   barItem   = graphPane.AddBar("--", pointPairList, Color.Blue);

            barItem.Label.IsVisible = false;

            zedGraphControl.RestoreScale(graphPane);
            pictureBox.Controls.Add(zedGraphControl);
        }
Beispiel #2
0
        public static void Merge(ZedGraphControl control)
        {
            var ppl = new PointPairList();

            foreach (var curve in control.GraphPane.CurveList)
            {
                for (var i = 0; i < curve.Points.Count; i++)
                {
                    ppl.Add(curve.Points[i]);
                }
            }
            ppl.Sort();

            for (var i = 1; i < ppl.Count; i++)
            {
                if (ppl[i].X != ppl[i - 1].X)
                {
                    continue;
                }

                ppl[i - 1].Y += ppl[i].Y;
                ppl.RemoveAt(i--);
            }

            control.GraphPane.CurveList.Clear();
            control.GraphPane.AddCurve("Merged", ppl, Rotator.NextColor, SymbolType.None);

            control.RestoreScale(control.GraphPane);
            control.Invalidate();
        }
Beispiel #3
0
        public void PrintGraph(int[,,] data, PictureBox picturebox, String text)
        {
            int[]           graph1          = CalPixelNum(data);
            ZedGraphControl zedGraphControl = new ZedGraphControl();

            zedGraphControl.Dock = DockStyle.Fill;
            zedGraphControl.IsSynchronizeXAxes                  = true;
            zedGraphControl.GraphPane.Title.IsVisible           = false;
            zedGraphControl.GraphPane.XAxis.Title.IsVisible     = false;
            zedGraphControl.GraphPane.YAxis.Title.IsVisible     = false;
            zedGraphControl.GraphPane.XAxis.Scale.FontSpec.Size = 10;
            zedGraphControl.GraphPane.YAxis.Scale.FontSpec.Size = 10;
            zedGraphControl.GraphPane.XAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsVisible = true;

            PointPairList pointPairList = new PointPairList();

            for (int i = 0; i < graph1.Length; i++)
            {
                pointPairList.Add(i, graph1[i]);
            }

            GraphPane graphPane = zedGraphControl.GraphPane;
            BarItem   barItem   = graphPane.AddBar(text, pointPairList, Color.Blue);

            zedGraphControl.RestoreScale(graphPane);
            picturebox.Controls.Add(zedGraphControl);
        }
Beispiel #4
0
        private void UpdateEnd(bool state)
        {
            ColorSymbolRotator color = new ColorSymbolRotator();

            // Even if an error occurs during downloads, maybe some values are OK
            for (int i = 0; i < CurvesNumber; i++)
            {
                LineItem l = m_zedGraphCtl.GraphPane.AddCurve("", Pointslists[i], color.NextColor, SymbolType.None);
                l.Line.Width = 2;
            }
            m_zedGraphCtl.GraphPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 190), 45F);

            m_zedGraphCtl.RestoreScale(m_zedGraphCtl.GraphPane);

            UseWaitCursor         = false;
            m_progressBar.Visible = false;

            if (state == false)
            {
                m_progresslabel.Text = "Error loading trend";
            }
            else
            {
                m_progresslabel.Visible = false;
            }

            m_list.Visible = true;
        }
Beispiel #5
0
        void initGraph()
        {
            pane.CurveList.Clear();
            pane.Title.Text            = chartTitle;
            pane.YAxis.Title.IsVisible = false;
            pane.XAxis.Title.Text      = "Time";
//			pane.XAxis.Title.IsVisible = false;
            pane.XAxis.Scale.Min = 0;
            graph.RestoreScale(pane);             // restore to default all zooming, etc.
//			pane.XAxis.AxisGap
            LineItem myCurve = pane.AddCurve("x", null, Color.Blue, SymbolType.None);

            pane.AddCurve("y", null, Color.Red, SymbolType.None);
            pane.AddCurve("z", null, Color.Green, SymbolType.None);
            graph.IsEnableHZoom     = true;
            graph.IsEnableVZoom     = false;
            graph.IsShowHScrollBar  = true;
            graph.IsAutoScrollRange = true;
            Update();
        }
Beispiel #6
0
        private void ClearData(ZedGraphControl zgc, bool update)
        {
            GraphPane myPane = zgc.GraphPane;

            myPane.CurveList.Clear();
            myPane.GraphObjList.Clear();

            if (update)
            {
                zgc.RestoreScale(myPane);
                UpdateGraph(zgc);
            }
        }
Beispiel #7
0
        private void CreateGraph(ZedGraphControl zgc)
        {
            GraphPane myPane = zgc.GraphPane;

            myPane.CurveList.Clear();

            string[] tags    = getValues <string>(_dtObs.Columns.IndexOf("ID"), _dtObs);
            double[] obs     = getValues <double>(_dtObs.Columns.IndexOf("Observation"), _dtObs);
            double[] est     = getValues <double>(_dtStats.Columns.IndexOf("Model_Prediction"), _dtStats);
            double[] pexceed = getValues <double>(_dtStats.Columns.IndexOf("Exceedance_Probability"), _dtStats);
            //double[] unbiased = getValues<double>(_dtStats.Columns.IndexOf("Unbiased_Estimate"), _dtStats);


            string plot = string.Empty;

            if (cboPlotList.SelectedIndex == 0)
            {
                plot   = "SampleValues_and_PredictedValues_ScatterPlot";
                myPane = addPlotXY(obs, est, tags, plot /*, unbiased */);
                if (cbPlotThreshold.Checked)
                {
                    myPane = addThresholdCurve(myPane, plot);
                }
            }
            else if (cboPlotList.SelectedIndex == 2)
            {
                plot   = "XY ScatterPlot (ProbExceed(Est) vs Observed)";
                myPane = addPlotPROB(obs, pexceed, tags, plot /*, unbiased */);
                if (cbPlotThreshold.Checked)
                {
                    myPane = addProbThresholdCurve(myPane);
                }
            }
            else
            {
                plot   = "SampleValues_and_PredictedValues_TimeSeries";
                myPane = addPlotTS(obs, est, tags, plot);
                if (cbPlotThreshold.Checked)
                {
                    myPane = addThresholdCurve(myPane, plot);
                }
            }

            myPane.XAxis.Cross = 0.0;
            zgc.AxisChange();
            zgc.Refresh();
            zgc.RestoreScale(myPane);
        }
Beispiel #8
0
        public FilteredPointDemo()
            : base("A demo demonstrating filtering of PointPairList.",
                   "Filtered Point Demo", DemoType.Line)
        {
            ZedGraphControl.IsShowPointValues = true;
            var points = new PointPairList();

            for (double i = 0; i <= 5.0; i += 1)
            {
                points.Add(i, i);
            }

            var curve = GraphPane.AddCurve("A Label", points, Color.ForestGreen);

            ZedGraphControl.RestoreScale(ZedGraphControl.GraphPane);
            ZedGraphControl.ZoomEvent += (sender, oldstate, newstate) => LogVisibility(sender, curve, points);
            ZedGraphControl.AxisChange();
        }
        private void buttonSimulate_Click(object sender, EventArgs e)
        {
            if (simulationManager.schedulers.Count == 0)
            {
                MessageBox.Show("There are no schedulers. Please add schedulers.");
                return;
            }


            if (simulationMode != SimulationMode.complete)
            {
                refreshStepDataGrid();
                simulationMode = SimulationMode.complete;
            }

            int pCount = processCount;

            double[] x = new double[pCount];

            for (int i = 1; i <= pCount; i++)
            {
                x[i - 1] = i;
            }

            Dictionary <Scheduler, double[]> database = simulationManager.MeanTurnaroundTime(pCount, backgroundWorker1);

            table.CurveList.Clear();
            foreach (var item in database)
            {
                LineItem tempLine =
                    table.AddCurve(item.Key.name, x, item.Value, item.Key.graphColor, SymbolType.VDash);
                tempLine.Line.Width = 3;
            }

            table.AxisChange();
            zed.RestoreScale(table);
        }
Beispiel #10
0
 internal void ResetAutoScale(LogGraphPane logGraphPane)
 {
     m_Graph.RestoreScale(logGraphPane);
 }
Beispiel #11
0
 public void Refresh()
 {
     control.RestoreScale(control.GraphPane);
     control.AxisChange();
     control.Invalidate();
 }
Beispiel #12
0
        /// <summary>
        /// 生成柱形图、折线图、饼图
        /// </summary>
        /// <param name="zgc"></param>
        public void CreateChart(ZedGraphControl zgc, DataTable dt)
        {
            string strChartType  = "";
            string strChartTitle = "图表";
            string strXAxisTitle = "分类(X)轴标志";
            string strYAxisTitle = "系列值";

            string[] XAxisLabel = null;
            double[] YAxisValue = null;

            try
            {
                GraphPane myPane = zgc.GraphPane;

                myPane.CurveList.Clear();
                myPane.GraphObjList.Clear();

                // 设置图表区域的背景色
                myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);
                myPane.Fill       = new Fill(Color.FromArgb(250, 250, 255));

                // 获取分类(X)轴标志和系列值
                int iRowCount = dt.Rows.Count;
                if (iRowCount > 0)
                {
                    for (int n = 0; n < g_stQuery.QueryCol.Length - 1; n++)
                    {
                        if (XAxisLabel == null &&
                            (g_stQuery.QueryCol[n].strChart.Equals("柱形图-分类(X)轴标志") || g_stQuery.QueryCol[n].strChart.Equals("折线图-分类(X)轴标志") || g_stQuery.QueryCol[n].strChart.Equals("饼图-分类(X)轴标志")))
                        {
                            XAxisLabel = new string[iRowCount];
                            for (int i = 0; i < iRowCount; i++)
                            {
                                XAxisLabel[i] = dt.Rows[i][g_stQuery.QueryCol[n].strColumn].ToString().Trim();
                            }
                            strXAxisTitle = g_stQuery.QueryCol[n].strNickName.Equals("") ? g_stQuery.QueryCol[n].strColumn : g_stQuery.QueryCol[n].strNickName;
                            strChartType  = g_stQuery.QueryCol[n].strChart.Split('-')[0];
                            strChartTitle = g_stQuery.strQueryName.Equals("") ? strChartType : g_stQuery.strQueryName;
                        }
                        else if (YAxisValue == null && g_stQuery.QueryCol[n].strChart.Equals("系列值"))
                        {
                            YAxisValue = new double[iRowCount];
                            for (int i = 0; i < iRowCount; i++)
                            {
                                YAxisValue[i] = Convert.ToDouble(dt.Rows[i][g_stQuery.QueryCol[n].strColumn]);
                            }
                            strYAxisTitle = g_stQuery.QueryCol[n].strNickName.Equals("") ? g_stQuery.QueryCol[n].strColumn : g_stQuery.QueryCol[n].strNickName;
                        }
                    }
                }

                // 设置图表标题
                myPane.Title.Text       = strChartTitle;
                myPane.XAxis.Title.Text = strXAxisTitle;  // 设置X轴的说明文字
                myPane.YAxis.Title.Text = strYAxisTitle;  // 设置Y轴的说明文字

                // 设置分类(X)轴标志
                myPane.XAxis.Scale.TextLabels = XAxisLabel;
                myPane.XAxis.Type             = AxisType.Text;

                // 设置系列值
                switch (strChartType)
                {
                case "柱形图":
                    // 生成柱状图
                    BarItem myBar = myPane.AddBar(strXAxisTitle, null, YAxisValue, Color.Blue);
                    myBar.Bar.Fill = new Fill(Color.Blue, Color.White, Color.Blue);
                    // 数值标注
                    //BarItem.CreateBarLabels(myPane, false, "");
                    myPane.XAxis.IsVisible           = true;  // 显示坐标轴
                    myPane.YAxis.IsVisible           = true;
                    myPane.XAxis.MajorGrid.IsVisible = false; // 隐藏X轴网格线
                    myPane.YAxis.MajorGrid.IsVisible = true;  // 显示Y轴网格线
                    break;

                case "折线图":
                    // 生成折线图
                    LineItem myLine = myPane.AddCurve(strXAxisTitle, null, YAxisValue, Color.Blue, SymbolType.None);
                    myLine.Line.Width                = 2;
                    myLine.Symbol.Fill               = new Fill(Color.White);
                    myPane.XAxis.IsVisible           = true;  // 显示坐标轴
                    myPane.YAxis.IsVisible           = true;
                    myPane.XAxis.MajorGrid.IsVisible = false; // 隐藏X轴网格线
                    myPane.YAxis.MajorGrid.IsVisible = true;  // 显示Y轴网格线
                    // 数值标注
                    //for (int i = 0; i < myLine.Points.Count; i++)
                    //{
                    //    PointPair pt = myLine.Points[i];
                    //    TextObj txt = new TextObj(pt.Y.ToString(), pt.X, pt.Y, CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
                    //    txt.ZOrder = ZOrder.A_InFront;
                    //    txt.FontSpec.Border.IsVisible = false;
                    //    txt.FontSpec.Fill.IsVisible = false;
                    //    txt.FontSpec.Angle = 0;
                    //    myPane.GraphObjList.Add(txt);
                    //}
                    break;

                case "饼图":
                    for (int i = 0; i < iRowCount; i++)
                    {
                        PieItem myPie = myPane.AddPieSlice(YAxisValue[i], Color.Blue, Color.White, 45F, 0, XAxisLabel[i]);
                        myPie.LabelType = PieLabelType.Name_Value_Percent;
                    }
                    myPane.XAxis.IsVisible = false;      // 隐藏坐标轴
                    myPane.YAxis.IsVisible = false;
                    break;

                default:
                    break;
                }

                zgc.AxisChange();             // 刷新数据
                zgc.Refresh();                // 刷新图表
                zgc.IsShowPointValues = true; // 设置显示节点值
                zgc.RestoreScale(myPane);     // 重置图表默认大小
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "CreateChart()");
            }
        }
Beispiel #13
0
 public static void Clear(ZedGraphControl control)
 {
     control.GraphPane.CurveList.Clear();
     control.RestoreScale(control.GraphPane);
     control.Invalidate();
 }
Beispiel #14
0
 public static void Draw(ZedGraphControl control, PointPairList ppl, string name = "Кривая")
 {
     control.GraphPane.AddCurve(name, ppl, Rotator.NextColor, SymbolType.None);
     control.RestoreScale(control.GraphPane);
     control.Invalidate();
 }