We help IT Professionals succeed at work.
Get Started

C# - ZedGraph Properties - Scale to Default.

ocaccy
ocaccy asked
on
5,205 Views
Last Modified: 2012-05-12
What is wrong?
The chart is mounted! But the data does not show.
Information has to plot.

  int id01 = -30;
            int id02 = -70;
            int id03 = 0;
            int id04 = -20;
            int id05 = -10;
            int id06 = 10;

            lista55m_1.Add(1,id01);
            lista55m_2.Add(2,id02);
            lista55m_3.Add(3,id03);
            lista55m_4.Add(4,id04);
            lista55m_5.Add(5,id05);
            lista55m_6.Add(6,id06);

If you click the right mouse button and choose Set Scale to Default, the points appear on the graph.
How do graphic normally be shown?
private void GRAPHICS55mm()
        {
            zed55mm.GraphPane.CurveList.Clear();
            {

                #region 2 mm zed55mm
                // GraphPane SETTINGS
                GraphPane myPane55m = zed55mm.GraphPane;

                //myPane55m.AddCurve("test curve", new ZedGraph.PointPairList(), Color.Red);
                myPane55m.Legend.IsVisible = true;
                //myPane55m.Legend.Position = LegendPos.Float;
                //myPane55m.Legend.Location = new Location(0.54, 0.02, CoordType.PaneFraction);
                myPane55m.Legend.FontSpec.Size = 18;
                myPane55m.Legend.Border.IsVisible = false;

                myPane55m.Fill.Color = System.Drawing.Color.Transparent;        // Setta a Cor no Grafico.
                myPane55m.Title.Text = "2µm - 7µm";                         // Setta o Titulo do Grafico.
                myPane55m.Title.FontSpec.Size = 29;


                // Y AXIS SETTINGS
                myPane55m.YAxis.Title.IsVisible = false;
                myPane55m.YAxis.MajorGrid.IsVisible = true;                     // Setta Linhas no Eixo Y ou seja na Horizontal.
                myPane55m.YAxis.MajorGrid.DashOff = 1;                          // Seta a Intensidade da Linha no Eixo Y.

                // X AXIS SETTINGS
                myPane55m.XAxis.Title.IsVisible = false;
                myPane55m.XAxis.MajorGrid.DashOff = 1;                          // Seta a Intensidade da Linha no Eixo X.
                myPane55m.XAxis.MajorGrid.IsVisible = true;                     // Setta Linhas no Eixo X ou seja na Vertical.

                myPane55m.XAxis.Scale.FontSpec.Angle = 0;                       // Setta o Angulo do Scale do Eixo X.
                myPane55m.XAxis.Scale.FontSpec.Family = "Arial, Narrow";        // Setta a Fonte da Scale no Eixo X.
                myPane55m.XAxis.Scale.FontSpec.FontColor = Color.Black;         // Setta a Cor da Legenda do Dado que Entrara no Eixo X.
                myPane55m.XAxis.Scale.FontSpec.IsBold = true;                   // Setta Negrito na Scale no Eixo X.
                myPane55m.XAxis.Scale.FontSpec.Size = 30;                       // Setta o Tamanho da Fonte da Scale no Eixo X.

                // Set the initial viewed range
  
                myPane55m.XAxis.Scale.IsSkipFirstLabel = true;
                myPane55m.XAxis.Scale.IsSkipLastLabel = true;
                myPane55m.XAxis.Scale.Min = 0;                                 // We want to use time from now
                myPane55m.XAxis.Scale.Max = 7;
                myPane55m.XAxis.Scale.MinorStep = 1;
                myPane55m.XAxis.Scale.MajorStep = 1;

 
                myPane55m.XAxis.Title.FontSpec.FontColor = Color.DarkViolet;    // Setta a Cor do Titulo no Eixo X.


                // Horizontal pan and zoom allowed
                zed55mm.IsEnableHPan = false;
                zed55mm.IsEnableHZoom = false;

                // Vertical pan and zoom not allowed
                zed55mm.IsEnableVPan = false;
                zed55mm.IsEnableVZoom = false;

                //show the cursor Value
                zed55mm.IsShowCursorValues = false;

                PointPairList lista55m_1 = new PointPairList();
                PointPairList lista55m_2 = new PointPairList();
                PointPairList lista55m_3 = new PointPairList();
                PointPairList lista55m_4 = new PointPairList();
                PointPairList lista55m_5 = new PointPairList();
                PointPairList lista55m_6 = new PointPairList();

                // Initially, a curve is added with no data points (list is empty)

                LineItem curve55m_1 = myPane55m.AddCurve("ID 01", lista55m_1, Color.Red, SymbolType.Square);
                curve55m_1.Line.IsSmooth = true;
                curve55m_1.Line.SmoothTension = 0.3F;
                curve55m_1.Symbol.Size = 8;

                LineItem curve55m_2 = myPane55m.AddCurve("ID_02", lista55m_2, Color.Blue, SymbolType.Triangle);
                curve55m_2.Line.IsSmooth = true;
                curve55m_2.Line.SmoothTension = 0.3F;
                curve55m_2.Symbol.Size = 8;

                LineItem curve55m_3 = myPane55m.AddCurve("ID_03", lista55m_3, Color.Black, SymbolType.Circle);
                curve55m_3.Line.IsSmooth = true;
                curve55m_3.Line.SmoothTension = 0.3F;
                curve55m_3.Symbol.Size = 8;

                LineItem curve55m_4 = myPane55m.AddCurve("ID_04", lista55m_4, Color.BurlyWood, SymbolType.Triangle);
                curve55m_4.Line.IsSmooth = true;
                curve55m_4.Line.SmoothTension = 0.3F;
                curve55m_4.Symbol.Size = 8;

                LineItem curve55m_5 = myPane55m.AddCurve("ID_05", lista55m_5, Color.Chartreuse, SymbolType.Triangle);
                curve55m_5.Line.IsSmooth = true;
                curve55m_5.Line.SmoothTension = 0.3F;
                curve55m_5.Symbol.Size = 8;

                LineItem curve55m_6 = myPane55m.AddCurve("ID_06", lista55m_6, Color.Coral, SymbolType.Triangle);
                curve55m_6.Line.IsSmooth = true;
                curve55m_6.Line.SmoothTension = 0.3F;
                curve55m_6.Symbol.Size = 8;

                // Scale the axes
                zed55mm.AxisChange();

                // Redraw the axes
                zed55mm.Invalidate();

                // Save the beginning time for reference
                //TickStart=Environment.TickCount;

                #endregion

            }
        }

Open in new window

private void Draw55(string id01_55,string id02_55,string id03_55,string id04_55,string id05_55,string id06_55)
            {
            // Get the first CurveItem in the graph
            LineItem curve55m_1 = zed55mm.GraphPane.CurveList[0] as LineItem;
            LineItem curve55m_2 = zed55mm.GraphPane.CurveList[1] as LineItem;
            LineItem curve55m_3 = zed55mm.GraphPane.CurveList[2] as LineItem;
            LineItem curve55m_4 = zed55mm.GraphPane.CurveList[3] as LineItem;
            LineItem curve55m_5 = zed55mm.GraphPane.CurveList[4] as LineItem;
            LineItem curve55m_6 = zed55mm.GraphPane.CurveList[5] as LineItem;
            if (curve55m_1 == null)
                return;
            if (curve55m_2 == null)
                return;
            if (curve55m_3 == null)
                return;
            if (curve55m_4 == null)
                return;
            if (curve55m_5 == null)
                return;
            if (curve55m_6 == null)
                return;

            //// Get the PointPairList
            IPointListEdit lista55m_1 = curve55m_1.Points as IPointListEdit;
            IPointListEdit lista55m_2 = curve55m_2.Points as IPointListEdit;
            IPointListEdit lista55m_3 = curve55m_3.Points as IPointListEdit;
            IPointListEdit lista55m_4 = curve55m_4.Points as IPointListEdit;
            IPointListEdit lista55m_5 = curve55m_5.Points as IPointListEdit;
            IPointListEdit lista55m_6 = curve55m_6.Points as IPointListEdit;
            // If this is null, it means the reference at curve.Points does not
            // support IPointListEdit, so we won't be able to modify it
            if (lista55m_1 == null)
                return;
            if (lista55m_2 == null)
                return;
            if (lista55m_3 == null)
                return;
            if (lista55m_4 == null)
                return;
            if (lista55m_5 == null)
                return;
            if (lista55m_6 == null)
                return;

            int id01 = -30;
            int id02 = -70;
            int id03 = 0;
            int id04 = -20;
            int id05 = -10;
            int id06 = 10;

            lista55m_1.Add(1,id01);
            lista55m_2.Add(2,id02);
            lista55m_3.Add(3,id03);
            lista55m_4.Add(4,id04);
            lista55m_5.Add(5,id05);
            lista55m_6.Add(6,id06);

            // Make sure the Y axis is rescaled to accommodate actual data
            //zed55mm.AxisChange();
            // Force a redraw
            //zed55mm.Invalidate();
            }

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE