当前位置: 首页>>代码示例>>C#>>正文


C# GraphPane.AxisChange方法代码示例

本文整理汇总了C#中ZedGraph.GraphPane.AxisChange方法的典型用法代码示例。如果您正苦于以下问题:C# GraphPane.AxisChange方法的具体用法?C# GraphPane.AxisChange怎么用?C# GraphPane.AxisChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZedGraph.GraphPane的用法示例。


在下文中一共展示了GraphPane.AxisChange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScaleAxisLabels

        /// <summary>
        /// Rescale font size of x axis labels when the graph is zoomed or resized.
        /// </summary>
        /// <param name="width">Width of the graph in pixels.</param>
        /// <param name="pane">GraphPane of the graph.</param>
        public static void ScaleAxisLabels(int width, GraphPane pane)
        {
            if (pane.XAxis.Scale.TextLabels == null)
                return;

            pane.XAxis.Scale.IsPreventLabelOverlap = false;
            int countLabels = (int) Math.Ceiling(pane.XAxis.Scale.Max - pane.XAxis.Scale.Min) + 1;

            float dxAvailable = (float) width / countLabels;

            var fontSpec = pane.XAxis.Scale.FontSpec;

            int pointSize;

            for (pointSize = 12; pointSize > 4; pointSize--)
            {
                using (var font = new Font(fontSpec.Family, pointSize))
                {
                    // See if the original labels fit with this font
                    int maxWidth = MaxWidth(font, pane.XAxis.Scale.TextLabels);
                    if (maxWidth <= dxAvailable)
                        break;
                }
            }

            pane.XAxis.Scale.FontSpec.Size = pointSize;
            pane.AxisChange();
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:33,代码来源:GraphUtilities.cs

示例2: SaveImage

        public void SaveImage(int width, int height, string title, string outputFile, ImageFormat imageFormat)
        {
            GraphPane myPane = new GraphPane(new RectangleF(0, 0, width, height), title, "Week", "Hours");
            myPane.IsBoundedRanges = true;

            var ppl = new PointPairList();
            foreach (var week in data)
            {
                ppl.Add(week.Item1, week.Item2);
            }

            // Hide the legend
            myPane.Legend.IsVisible = false;
            var foreground = Color.FromArgb(255, 55, 108, 153);

            myPane.XAxis.AxisGap = 1f;
            myPane.XAxis.Type = AxisType.Text;
            myPane.XAxis.Scale.TextLabels = data.Select(t => "Week " + t.Item1).ToArray();

            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.MinorStep = 1;
            myPane.YAxis.MinorTic.Color = Color.Transparent;

            myPane.Border.IsVisible = false;

            LineItem curve = myPane.AddCurve("Hours of effort", ppl, foreground, SymbolType.Circle);
            curve.Line.Width = 2.0F;
            curve.Line.IsAntiAlias = true;
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Symbol.Size = 7;

            // Leave some extra space on top for the labels to fit within the chart rect
            myPane.YAxis.Scale.MaxGrace = 0.1;

            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45);
            myPane.Fill = new Fill(Color.White);

            Bitmap bm = new Bitmap(1, 1);
            using (Graphics g = Graphics.FromImage(bm))
                myPane.AxisChange(g);

            myPane.GetImage().Save(outputFile, imageFormat);
        }
开发者ID:miklund,项目名称:TogglChart,代码行数:43,代码来源:Graph.cs

示例3: AllowMagnitudeScalingToEpsilon

        public void AllowMagnitudeScalingToEpsilon()
        {
            int height = 720;
            int width = 1280;

            var min = double.Epsilon;
            var max = min * 2;

            int expectedScale = -324;

            GraphPane graphPane = new GraphPane();
            graphPane.AddCurve(string.Empty, new[] { min, max }, new[] { min, max }, Color.Blue, SymbolType.None);

            Bitmap bitmap = new Bitmap(width, height);
            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                graphPane.AxisChange(graphics);
            }

            Assert.That(graphPane.YAxis.Scale.Mag, Is.EqualTo(expectedScale));
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:21,代码来源:ScaleTests.cs

示例4: ClusteredBarGraph

        public void ClusteredBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Clustered Bar Graph Test", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 98, 40, -10 };
            double[] y2 = { 90, 100, 95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, 18 };

            double[] y4 = { 120, 125, 100, 20, 105, 75, -40 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //Add Labels to the curves

            //	Shift	the text items up by	5 user	scale units	above	the	bars
            const float shift = 5;

            for ( int i = 0; i < y.Length; i++ )
            {
                //	format	the label string to	have	1 decimal place
                string lab = y2[i].ToString( "F1" );
                //	create	the text item (assumes	the	x	axis is	ordinal or	text)
                //	for negative bars, the	label appears just	above	the zero	value
                TextObj text = new TextObj( lab, (float)( i + 1 ), (float)( y2[i] < 0 ? 0.0 : y2[i] ) + shift );
                //	tell	Zedgraph to use user	scale units	for locating	the	TextObj
                text.Location.CoordinateFrame = CoordType.AxisXYScale;
                //	Align the left-center	of the text to the	specified	point
                text.Location.AlignH = AlignH.Left;
                text.Location.AlignV = AlignV.Center;
                text.FontSpec.Border.IsVisible = false;
                //	rotate the	text 90 degrees
                text.FontSpec.Angle = 90;
                //	add the	TextObj to	the	list
                testee.GraphObjList.Add( text );
            }

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.YAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a clustered bar graph having the proper number of bars per x-Axis point visible ?  <Next Step: Resize the chart>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all x-Axis labels visible?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:71,代码来源:ZGTest.cs

示例5: AnimatedDateGraph

        public void AnimatedDateGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Date	Graph	Test ", "X AXIS", "Y Value" );

            //	start	with an empty list for testing
            PointPairList pointList = new PointPairList();

            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            LineItem myCurve = testee.AddCurve( "My	Curve",
                pointList, Color.Red, SymbolType.Diamond );

            //	Set the XAxis	to date type
            testee.XAxis.Type = AxisType.Date;

            //	make the	symbols filled blue
            myCurve.Symbol.Fill.Type = FillType.Solid;
            myCurve.Symbol.Fill.Color = Color.Blue;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            //	Draw a sinusoidal curve, adding one	point at a	time
            //	and refiguring/redrawing each time.	(a stress test)
            //	redo	creategraphics()	each time to stress test
            for ( int i = 0; i < 300; i++ )
            {
                double x = (double)new XDate( 1995, i + 1, 1 );
                double y = Math.Sin( (double)i * Math.PI / 30.0 );

                ( myCurve.Points as PointPairList ).Add( x, y );
                testee.AxisChange( form2.CreateGraphics() );
                form2.Refresh();

                //	delay for 10 ms
                //DelaySeconds(	50	);
            }

            while ( myCurve.Points.Count > 0 )
            {
                //	remove the	first point	in the list
                ( myCurve.Points as PointPairList ).RemoveAt( 0 );
                testee.AxisChange( form2.CreateGraphics() );
                form2.Refresh();

                //	delay for 10 ms
                //DelaySeconds(	50	);
            }

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did you see points added one by one, then deleted one by one?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:54,代码来源:ZGTest.cs

示例6: AllNaN

        public void AllNaN()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "My Test NaN Graph", "Date", "My	Y	Axis" );

            //	Make up some random data points
            double[] x = new double[36];
            double[] y = new double[36];
            for ( int i = 0; i < 36; i++ )
            {
                x[i] = (double)new XDate( 1995, i + 1, 1 );
                y[i] = System.Double.NaN;
            }
            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            CurveItem myCurve = testee.AddCurve( "My Curve",
                x, y, Color.Red, SymbolType.Circle );
            //	Set the XAxis	to date type
            testee.XAxis.Type = AxisType.Date;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Do you see a graph with all values missing (NaN's)?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:29,代码来源:ZGTest.cs

示例7: FindNearestObject


//.........这里部分代码省略.........
            bar.Tag = "Curly";
            //Brush brush = new HatchBrush( HatchStyle.Cross, Color.AliceBlue, Color.Red );
            //GraphicsPath path = new GraphicsPath();
            //path.AddLine( 10, 10, 20, 20 );
            //path.AddLine( 20, 20, 30, 0 );
            //path.AddLine( 30, 0, 10, 10 );

            //brush = new PathGradientBrush( path );
            //bar.Bar.Fill = new Fill( brush );

            testee.BarSettings.ClusterScaleWidth = 100;
            testee.BarSettings.Type = BarType.Stack;

            testee.Fill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
            testee.Chart.Fill = new Fill( Color.White, Color.FromArgb( 255, 255, 166 ), 90F );

            testee.XAxis.MajorGrid.IsVisible = true;
            testee.YAxis.MajorGrid.IsVisible = true;
            testee.YAxis.Scale.Max = 120;
            testee.Y2Axis.IsVisible = true;
            testee.Y2Axis.Scale.Max = 120;

            TextObj text = new TextObj( "First Prod\n21-Oct-93", 175F, 80.0F );
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill = new Fill( Color.White, Color.PowderBlue, 45F );
            text.Tag = "First";
            testee.GraphObjList.Add( text );

            ArrowObj arrow = new ArrowObj( Color.Black, 12F, 175F, 77F, 100F, 45F );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            testee.GraphObjList.Add( arrow );

            text = new TextObj( "Upgrade", 700F, 50.0F );
            text.FontSpec.Angle = 90;
            text.FontSpec.FontColor = Color.Black;
            text.Location.AlignH = AlignH.Right;
            text.Location.AlignV = AlignV.Center;
            text.FontSpec.Fill.IsVisible = false;
            text.FontSpec.Border.IsVisible = false;
            testee.GraphObjList.Add( text );

            arrow = new ArrowObj( Color.Black, 15, 700, 53, 700, 80 );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.Line.Width = 2.0F;
            arrow.Tag = "Arrow";
            testee.GraphObjList.Add( arrow );

            text = new TextObj( "Confidential", 0.8F, -0.03F );
            text.Location.CoordinateFrame = CoordType.ChartFraction;

            text.FontSpec.Angle = 15.0F;
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color = Color.Red;
            text.FontSpec.Fill.IsVisible = false;

            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            testee.GraphObjList.Add( text );

            testee.IsPenWidthScaled = false;

            EllipseObj ellipse = new EllipseObj( 500, 50, 200, 20, Color.Blue,
                Color.Goldenrod );
            ellipse.Location.CoordinateFrame = CoordType.AxisXYScale;
            ellipse.Tag = "Ellipse";
            testee.GraphObjList.Add( ellipse );

            //			Bitmap bm = new Bitmap( @"c:\temp\sunspot.jpg" );
            Bitmap bm = new Bitmap( @"c:\windows\winnt256.bmp" );
            Image image = Image.FromHbitmap( bm.GetHbitmap() );
            ImageObj imageItem = new ImageObj( image, new RectangleF( 0.8F, 0.8F, 0.2F, 0.2F ),
                CoordType.ChartFraction, AlignH.Left, AlignV.Top );
            imageItem.IsScaled = true;
            imageItem.Tag = "Bitmap";
            testee.GraphObjList.Add( imageItem );

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            TestUtils.ShowMessage( "For each step, read the message in the Title Bar of the form" );

            HandleFind( "Select the ellipse object", "Ellipse", 0, typeof( GraphObj ) );
            HandleFind( "Select the 'First Prod' text object", "First", 0, typeof( GraphObj ) );
            HandleFind( "Select the upgrade arrow object", "Arrow", 0, typeof( GraphObj ) );
            HandleFind( "Select the Graph Title", "", 0, typeof( GraphPane ) );
            HandleFind( "Select the X Axis", "ZedGraph.XAxis", 0, typeof( Axis ) );
            HandleFind( "Select the Y Axis", "ZedGraph.YAxis", 0, typeof( Axis ) );
            HandleFind( "Select the Y2 Axis", "ZedGraph.Y2Axis", 0, typeof( Axis ) );
            HandleFind( "Select the second curve in the legend", "", 1, typeof( Legend ) );
            HandleFind( "Select the tallest blue bar", "Curly", 6, typeof( CurveItem ) );
            HandleFind( "Select the negative brown bar", "Wheezy", 2, typeof( CurveItem ) );
            HandleFind( "Select the negative blue bar", "Curly", 2, typeof( CurveItem ) );
            HandleFind( "Select the highest green circle symbol", "Larry", 6, typeof( CurveItem ) );
            HandleFind( "Select the windows bitmap object", "Bitmap", 0, typeof( GraphObj ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:101,代码来源:ZGTest.cs

示例8: LongFeature

        public void LongFeature()
        {
            bool userOK = TestUtils.waitForUserOK;

            if ( MessageBox.Show( "Do you want to prompt at each step (otherwise, I will just run through" +
                " the whole test)?  Pick YES to Prompt at each step", "Test Setup",
                MessageBoxButtons.YesNo ) == DialogResult.No )
            {
                TestUtils.waitForUserOK = false;
            }

            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "My Test Dual Y Graph", "Date", "My	Y	Axis" );

            //	Make up some random data points
            double[] x = new double[36];
            double[] y = new double[36];
            double[] y2 = new double[36];
            for ( int i = 0; i < 36; i++ )
            {
                x[i] = (double)i * 5.0;
                y[i] = Math.Sin( (double)i * Math.PI / 15.0 ) * 16.0;
                y2[i] = y[i] * 10.5;
            }
            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            CurveItem myCurve = testee.AddCurve( "My Curve",
                x, y, Color.Red, SymbolType.Diamond );

            //	Generate a blue curve with	diamond
            //	symbols, and "My Curve" in the legend
            myCurve = testee.AddCurve( "My Curve	1",
                x, y2, Color.Blue, SymbolType.Circle );
            myCurve.IsY2Axis = true;

            testee.XAxis.MajorGrid.IsVisible = false;
            testee.XAxis.IsVisible = false;
            testee.XAxis.MajorGrid.IsZeroLine = false;
            testee.XAxis.MajorTic.IsOutside = false;
            testee.XAxis.MinorTic.IsOutside = false;
            testee.XAxis.MajorTic.IsInside = false;
            testee.XAxis.MinorTic.IsInside = false;
            testee.XAxis.MinorTic.IsOpposite = false;
            testee.XAxis.MajorTic.IsOpposite = false;
            testee.XAxis.Scale.IsReverse = false;
            //	testee.XAxis.IsLog = false;
            testee.XAxis.Title.Text = "";

            testee.YAxis.MajorGrid.IsVisible = false;
            testee.YAxis.IsVisible = false;
            testee.YAxis.MajorGrid.IsZeroLine = false;
            testee.YAxis.MajorTic.IsOutside = false;
            testee.YAxis.MinorTic.IsOutside = false;
            testee.YAxis.MajorTic.IsInside = false;
            testee.YAxis.MinorTic.IsInside = false;
            testee.YAxis.MinorTic.IsOpposite = false;
            testee.YAxis.MajorTic.IsOpposite = false;
            testee.YAxis.Scale.IsReverse = false;
            //testee.YAxis.IsLog =	false;
            testee.YAxis.Title.Text = "";

            testee.Y2Axis.MajorGrid.IsVisible = false;
            testee.Y2Axis.IsVisible = false;
            testee.Y2Axis.MajorGrid.IsZeroLine = false;
            testee.Y2Axis.MajorTic.IsOutside = false;
            testee.Y2Axis.MinorTic.IsOutside = false;
            testee.Y2Axis.MajorTic.IsInside = false;
            testee.Y2Axis.MinorTic.IsInside = false;
            testee.Y2Axis.MinorTic.IsOpposite = false;
            testee.Y2Axis.MajorTic.IsOpposite = false;
            testee.Y2Axis.Scale.IsReverse = false;
            //testee.Y2Axis.IsLog = false;
            testee.Y2Axis.Title.Text = "";

            testee.Chart.Border.IsVisible = false;
            testee.Border.IsVisible = false;

            testee.Title.IsVisible = false;
            testee.Legend.IsHStack = false;
            testee.Legend.IsVisible = false;
            testee.Legend.Border.IsVisible = false;
            testee.Legend.Fill.Type = FillType.None;
            testee.Legend.Position = LegendPos.Bottom;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Do you see a dual Y graph with no axes?" ) );

            testee.Border = new Border( true, Color.Red, 3.0F );

            form2.Refresh();
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Pane Frame Added?" ) );

            testee.Border = new Border( Color.Black, 1.0F );

//.........这里部分代码省略.........
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:101,代码来源:ZGTest.cs

示例9: TextAxis

        public void TextAxis()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Text Graph", "Label", "Y Value" );

            //	Make up some random data points
            string[] labels = { "USA", "Spain", "Qatar",	"Morocco", "UK", "Uganda",
                                  "Cambodia", "Malaysia",	"Australia", "Ecuador" };

            double[] y = new double[10];
            for ( int i = 0; i < 10; i++ )
                y[i] = Math.Sin( (double)i * Math.PI / 2.0 );
            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            CurveItem myCurve = testee.AddCurve( "My Curve",
                null, y, Color.Red, SymbolType.Diamond );
            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            //	Set the labels at	an angle so they	don't overlap
            testee.XAxis.Scale.FontSpec.Angle = 0;
            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did you	get	an	X	Text axis?" ) );

            ( myCurve.Points as PointPairList ).Clear();
            for ( double i = 0; i < 100; i++ )
                ( myCurve.Points as PointPairList ).Add( i / 10.0, Math.Sin( i / 10.0 * Math.PI / 2.0 ) );

            testee.AxisChange( form2.CreateGraphics() );
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the points fill in between the labels? (Next Resize the graph and check label overlap again)" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:44,代码来源:ZGTest.cs

示例10: StkBarGraph

        public void StkBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Stack Bar	Graph	Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 0, 40, -10 };
            double[] y2 = { 90, 100, -95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, -18 };

            double[] y4 = { 120, 125, 100, 20, 105, 75, -40 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	stack bar
            testee.BarSettings.Type = BarType.Stack;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;
            //turn	off pen width	scaling
            testee.IsPenWidthScaled = false;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a stack bar graph having three bars per x-Axis point visible ?  <Next Step: Maximize the display>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all x-Axis labels visible?  <Next Step: Add a curve>" ) );

            LineItem curve = new LineItem( "Curve A", null, y4, Color.Black, SymbolType.TriangleDown );
            testee.CurveList.Insert( 0, curve );
            curve.Line.Width = 1.5F;
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            curve.Symbol.Fill = new Fill( Color.Yellow );
            curve.Symbol.Size = 8;

            form2.Refresh();

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Was a new curve displayed on top of the bars?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:63,代码来源:ZGTest.cs

示例11: SortedOverlayBarGraph

        public void SortedOverlayBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Sorted Overlay Bar Graph Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, -115, 75, 22, 98, 40, 10 };
            double[] y2 = { 90, -100, 95, -35, 0, 35, 35 };
            double[] y3 = { 80, -110, 65, 15, 54, 67, 18 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y3, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	overlay bars
            testee.BarSettings.Type = BarType.SortedOverlay;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //	Shift	the text items up by	5 user	scale units	above	the	bars
            const float shift = 5;

            string lab = "";
            TextObj text = null;
            for ( int x = 0; x < 3; x++ )
                for ( int i = 0; i < y.Length; i++ )
                {
                    //	format	the label string to	have	1 decimal place
                    switch ( x )
                    {
                        case 0:
                            lab = y[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y[i] < 0 ? y[i] + 2 * shift : y[i] ) - shift );
                            break;
                        case 1:
                            lab = y2[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y2[i] < 0 ? y2[i] + 2 * shift : y2[i] ) - shift );
                            break;
                        case 2:
                            lab = y3[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y3[i] < 0 ? y3[i] + 2 * shift : y3[i] ) - shift );
                            break;
                        default:
                            break;
                    }
                    text.FontSpec.Size = 4;
                    text.FontSpec.IsBold = true;
                    //	tell	Zedgraph to use user	scale units	for locating	the	TextObj
                    text.Location.CoordinateFrame = CoordType.AxisXYScale;
                    //	Align the left-center	of the text to the	specified	point
                    text.Location.AlignH = AlignH.Center;
                    text.Location.AlignV = AlignV.Center;
                    text.FontSpec.Border.IsVisible = false;
                    //	add the	TextObj to	the	list
                    testee.GraphObjList.Add( text );
                }

            form2.WindowState = FormWindowState.Maximized;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.YAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a Sorted Overlay Stack Bar displayed with the segments in increasing value order as indicated by the embedded values? " ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:85,代码来源:ZGTest.cs

示例12: SmoothCurve

        public void SmoothCurve()
        {
            //			memGraphics.CreateDoubleBuffer( form2.CreateGraphics(),
            //				form2.ClientRectangle.Width,	form2.ClientRectangle.Height );

            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Text Graph", "Label", "Y Value" );

            //	Make up some random data points
            string[] labels = { "USA", "Spain", "Qatar",	"Morocco", "UK", "Uganda",
                                  "Cambodia", "Malaysia",	"Australia", "Ecuador" };

            PointPairList points = new PointPairList();
            double numPoints = 10.0;
            for ( double i = 0; i < numPoints; i++ )
                points.Add( i / ( numPoints / 10.0 ) + 1.0, Math.Sin( i / ( numPoints / 10.0 ) * Math.PI / 2.0 ) );

            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            LineItem myCurve = testee.AddCurve( "My	Curve",
                points, Color.Red, SymbolType.Diamond );
            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            //	Set the labels at	an angle so they	don't overlap
            testee.XAxis.Scale.FontSpec.Angle = 0;
            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            myCurve.Line.IsSmooth = true;

            for ( float tension = 0.0F; tension < 3.0F; tension += 0.1F )
            {
                myCurve.Line.SmoothTension = tension;
                form2.Refresh();

                TestUtils.DelaySeconds( 50 );
            }
            for ( float tension = 3.0F; tension >= 0F; tension -= 0.1F )
            {
                myCurve.Line.SmoothTension = tension;
                form2.Refresh();

                TestUtils.DelaySeconds( 50 );
            }

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did you see varying levels of smoothing?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:51,代码来源:ZGTest.cs

示例13: SingleValue

        public void SingleValue()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Wacky	Widget Company\nProduction Report",
                "Time, Years\n(Since Plant Construction Startup)",
                "Widget Production\n(units/hour)" );

            double[] x = { 0.4875 };
            double[] y = { -123456 };

            LineItem curve;
            curve = testee.AddCurve( "One	Value", x, y, Color.Red, SymbolType.Diamond );
            curve.Symbol.Fill.Type = FillType.Solid;

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

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Do you see a single value in the middle of the scale ranges?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:24,代码来源:ZGTest.cs

示例14: DualY

        public void DualY()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "My Test Dual Y Graph", "Date", "My	Y Axis" );
            testee.Y2Axis.Title.Text = "My Y2 Axis";

            //	Make up some random data points
            double[] x = new double[36];
            double[] y = new double[36];
            double[] y2 = new double[36];
            for ( int i = 0; i < 36; i++ )
            {
                x[i] = (double)new XDate( 1995, i + 1, 1 );
                y[i] = Math.Sin( (double)i * Math.PI / 15.0 );
                y2[i] = y[i] * 3.6178;
            }
            //	Generate a red	curve with diamond
            //	symbols, and "My Curve" in the legend
            CurveItem myCurve = testee.AddCurve( "My Curve",
                x, y, Color.Red, SymbolType.Diamond );
            //	Set the XAxis	to date type
            testee.XAxis.Type = AxisType.Date;

            //	Generate a blue curve with	diamond
            //	symbols, and "My Curve" in the legend
            myCurve = testee.AddCurve( "My Curve	1",
                x, y2, Color.Blue, SymbolType.Circle );
            myCurve.IsY2Axis = true;
            testee.YAxis.IsVisible = true;
            testee.Y2Axis.IsVisible = true;
            testee.Y2Axis.MajorGrid.IsVisible = true;
            testee.XAxis.MajorGrid.IsVisible = true;
            testee.YAxis.MajorTic.IsOpposite = false;
            testee.YAxis.MinorTic.IsOpposite = false;
            testee.YAxis.MajorGrid.IsZeroLine = false;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Show();

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Do you see a dual Y graph?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:45,代码来源:ZGTest.cs

示例15: CreateTokenMatchGraph

        private void CreateTokenMatchGraph(OSPCResult r)
        {
            GraphPane g = new GraphPane(GraphRect, "Distribution of token / match", "-", "Token / match");
            SetupGraph(g);

            var lst = r.Results.Select(i => (double)i.TokenCount / (double)i.MatchCount).OrderBy(i => i).ToArray();

            var c = g.AddCurve("Token / match",
                Enumerable.Range(1, lst.Length).Select(i => (double)i).ToArray(),
                lst,
                Color.Red);
            c.Symbol.IsVisible = false;

            #if SHOW_DERIVATION_2
            var derv_2 = lst.CalcDerv2();
            c = g.AddCurve("Derivation 2",
                Enumerable.Range(1, derv_2.Length).Select(i => (double)i).ToArray(),
                derv_2.ToArray(),
                Color.Green);
            c.IsY2Axis = true;
            c.Symbol.IsVisible = false;
            #endif

            AddLine(g, r.AVG_TokenPerMatch, Color.Blue, "Avg");
            AddLine(g, r.POI_TokenPerMatch, Color.Green, "POI");

            g.AxisChange();
            using (var img = g.GetImage())
            {
                img.Save(Path.Combine(OutPath, "TokenMatchGraph.png"), ImageFormat.Png);
            }
        }
开发者ID:arthurzaczek,项目名称:OSPC,代码行数:32,代码来源:HtmlReporter.cs


注:本文中的ZedGraph.GraphPane.AxisChange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。