Ejemplo n.º 1
0
        private void GenerateRangeGraphAndTable()
        {
            #region Write graph
            GraphPane graphPane = new GraphPane(new Rectangle(0, 0, 420, 280), "", "", "");

            graphPane.CurveList.Clear();
            graphPane.XAxis.Title = "Test Series";
            graphPane.YAxis.Title = "Response time in milliseconds";

            PointPairList list1 = new PointPairList();
            PointPairList hList = new PointPairList();

            int count = 0;
            foreach (TestDataElement d in testDataList)
            {
                count++;
                list1.Add(count, d.avgResponseTime);
                hList.Add(count, d.maxResponseTime, d.minResponseTime);
            }

            ErrorBarItem rangebar = graphPane.AddErrorBar("Range", hList, Color.Blue);
            rangebar.ErrorBar.PenWidth = 3;
            rangebar.ErrorBar.Symbol.IsVisible = false;

            LineItem curve = graphPane.AddCurve("Average", list1, Color.Red, SymbolType.Default);
            curve.Line.IsVisible = true;
            curve.Line.IsSmooth = false;
            curve.Symbol.Size = 4;
            curve.Symbol.Fill = new Fill(Color.Red);
            curve.Line.Fill = new Fill(Color.White, Color.LightSkyBlue, -45F);

            graphPane.XAxis.IsShowGrid = true;
            graphPane.YAxis.IsShowGrid = true;
            graphPane.XAxis.Max = testDataList.Count+1;

            SaveGraphImage(graphPane, reportPath + @"\range.png");
            #endregion

            #region Write table
            // write table header
            rangeTable = new StringBuilder();
            rangeTable.Append("<table><thead><tr>\n");
            rangeTable.Append("<th width=\"25%\">Thread</th>\n");
            rangeTable.Append("<th width=\"25%\">Mean response</th>\n");
            rangeTable.Append("<th width=\"25%\">Min response</th>\n");
            rangeTable.Append("<th width=\"25%\">Max response</th>\n");
            rangeTable.Append("</tr></thead><tbody>\n");
            count = 0;
            bool oddline = true;
            foreach (TestDataElement d in testDataList)
            {
                count++;
                if (oddline == true)
                    rangeTable.Append("<tr class=\"odd\">\n");
                else
                    rangeTable.Append("<tr class=\"even\">\n");

                rangeTable.Append("<td class=\"s\">");
                rangeTable.AppendFormat("{0}", count);
                rangeTable.Append("</td>\n");

                rangeTable.Append("<td class=\"s\">");
                rangeTable.AppendFormat("{0:f2}", d.avgResponseTime);
                rangeTable.Append("</td>\n");

                rangeTable.Append("<td class=\"s\">");
                rangeTable.AppendFormat("{0:f2}", d.minResponseTime);
                rangeTable.Append("</td>\n");

                rangeTable.Append("<td class=\"s\">");
                rangeTable.AppendFormat("{0:f2}", d.maxResponseTime);
                rangeTable.Append("</td>\n");
                oddline = !oddline;
            }
            rangeTable.Append("</tr></table>\n");
            #endregion
        }
Ejemplo n.º 2
0
        public void ErrorBarChart()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "ErrorBar Chart Test ", "X AXIS", "Y Value" );

            double[] hi = new double[20];
            double[] low = new double[20];
            double[] x = new double[20];

            for ( int i = 45; i < 65; i++ )
            {
                x[i - 45] = (double)new XDate( 2004, 12, i - 30, 0, 0, 0 );
                if ( i % 2 == 1 )
                    hi[i - 45] = (double)i * 1.03;
                else
                    hi[i - 45] = (double)i * .99;

                low[i - 45] = .97 * hi[i - 45];
            }

            ErrorBarItem myCurve = testee.AddErrorBar( "My	Curve", x, hi, low, Color.Blue );

            testee.XAxis.Scale.FontSpec.Size = 12;
            testee.XAxis.Scale.FontSpec.Angle = 90;

            //	Set the XAxis	to date type
            testee.XAxis.Type = AxisType.Date;
            testee.XAxis.Scale.Min = x[0] - 1;
            myCurve.Bar.PenWidth = 2;

            testee.YAxis.MajorGrid.IsVisible = true;
            testee.YAxis.MinorGrid.IsVisible = true;

            form2.WindowState = FormWindowState.Maximized;
            testee.AxisChange( form2.CreateGraphics() );

            TestUtils.DelaySeconds( 3000 );
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Was the typical Error Bar chart with a date X-Axis displayed?" ) );
        }
        private void initializeGraphControl (ZedGraphControl zedGraphControl)
        {
            zedGraphControl.MasterPane.PaneList.Clear();
            zedGraphControl.MasterPane.SetLayout(zedGraphControl.CreateGraphics(), 1, (int) IonSeries.Count + 1);
            zedGraphControl.MasterPane.InnerPaneGap = 0;
            zedGraphControl.MasterPane.Border.IsVisible = true;
            zedGraphControl.IsEnableHPan = false;
            zedGraphControl.IsEnableHZoom = false;
            zedGraphControl.IsSynchronizeYAxes = true;
            zedGraphControl.IsZoomOnMouseCenter = true;

            var axisPane = new GraphPane();
            axisPane.Legend.IsVisible = false;
            axisPane.IsFontsScaled = false;
            axisPane.XAxis.IsVisible = false;
            axisPane.YAxis.Scale.Min = 0;
            axisPane.YAxis.Scale.Max = 100;
            axisPane.YAxis.Title.Text = zedGraphControl.Text;
            axisPane.YAxis.Title.Gap = 0.05f;
            axisPane.YAxis.MajorTic.IsOpposite = false;
            axisPane.YAxis.MinorTic.IsOpposite = false;
            axisPane.Chart.Border.IsVisible = false;
            axisPane.Border.IsVisible = false;
            axisPane.Margin.Left = 1;
            axisPane.Margin.Right = 0;
            axisPane.Title.Text = "Series:";
            zedGraphControl.MasterPane.Add(axisPane);

            var csr = new ColorSymbolRotator();
            for (int i = 0; i < (int) IonSeries.Count; ++i)
            {
                var graphPane = new GraphPane();
                graphPane.Title.Text = IonSeriesLabels[i];
                graphPane.Legend.IsVisible = false;
                graphPane.IsFontsScaled = false;
                graphPane.Chart.Border.IsVisible = false;
                graphPane.Border.IsVisible = false;
                graphPane.XAxis.Scale.Min = -1;
                graphPane.XAxis.Scale.Max = 1;
                graphPane.XAxis.IsVisible = false;
                graphPane.YAxis.Scale.Min = 0;
                graphPane.YAxis.Scale.Max = 100;
                graphPane.YAxis.IsVisible = false;
                zedGraphControl.MasterPane.Add(graphPane);

                graphPane.BarSettings.Type = BarType.Overlay;
                graphPane.BarSettings.ClusterScaleWidth = 1;

                var mean = graphPane.AddCurve(IonSeriesLabels[i],
                                              new PointPairList(),
                                              Color.Black,
                                              SymbolType.Circle);
                mean.Line.IsVisible = false;
                mean.Symbol.Border.IsVisible = false;
                mean.Symbol.Fill.Type = FillType.Solid;

                var errorBar = graphPane.AddErrorBar(IonSeriesLabels[i],
                                                     new PointPairList(),
                                                     Color.Black);
                errorBar.Bar.IsVisible = true;
                errorBar.Bar.PenWidth = .1f;
                errorBar.Bar.Symbol.IsVisible = true;
                errorBar.Bar.Symbol.Type = SymbolType.HDash;
                errorBar.Bar.Symbol.Border.Width = .1f;
                errorBar.Bar.Symbol.Size = 4;

                var hiLowBar = graphPane.AddHiLowBar(IonSeriesLabels[i],
                                                     new PointPairList(),
                                                     Color.Black);
                hiLowBar.Bar.Fill.Type = FillType.None;

                var scatter = graphPane.AddCurve(IonSeriesLabels[i],
                                                 new PointPairList(),
                                                 csr.NextColor,
                                                 SymbolType.Circle);
                scatter.Line.IsVisible = false;
                scatter.Symbol.IsAntiAlias = true;
                scatter.Symbol.Border.IsVisible = false;
                scatter.Symbol.Fill.Type = FillType.Solid;
                scatter.Symbol.Size = 3f;
            }

            zedGraphControl.MasterPane.AxisChange();
            zedGraphControl.Refresh();
        }