0

i have a working program where i can add an array to a Zedgraph and show this in a form. Now i only want to change the display of the x-axis from points (0..400) to frequency (9e3..6e9 Hz). Here are my currently working functions:

public void AddGraph(double[] Values, string LegendName)
{
    int i = 0;
    PointPairList list = new PointPairList();

    for (i = 0; i < Values.Length; i++)
    {
        list.Add(i, Values[i]);
    }

    if (i > MaxXAxis)
        MaxXAxis = i;

    SList.Add(list);
    SListColor.Add(Color.Black);
    }
    SListName.Add(LegendName);
}


public void ShowDiagram(string Title, string XAxisName, string YAxisName, 
                         int Timeout_ms)
    {
        ZedGraph.ZedGraphControl zgc = new ZedGraphControl();
        GraphPane myPane = zgc.GraphPane;

        LineItem myCurve = null;

        // Set the titles and axis labels
        myPane.Title.Text = Title;
        myPane.XAxis.Title.Text = XAxisName;
        myPane.YAxis.Title.Text = YAxisName;

        for (int i = 0; i < SList.Count(); i++)
        {
            myCurve = myPane.AddCurve(SListName[i], SList[i], SListColor[i], 
                      SymbolType.None);
            myCurve.Line.Width = 2;
        }

        // Add gridlines to the plot, and make them gray
        myPane.XAxis.MinorGrid.IsVisible = true;
        myPane.YAxis.MinorGrid.IsVisible = true;
        myPane.XAxis.MinorGrid.Color = Color.LightGray;
        myPane.YAxis.MinorGrid.Color = Color.LightGray;
        myPane.XAxis.MinorGrid.DashOff = 0;
        myPane.YAxis.MinorGrid.DashOff = 0;

        myPane.XAxis.MajorGrid.IsVisible = true;
        myPane.YAxis.MajorGrid.IsVisible = true;
        myPane.XAxis.MajorGrid.Color = Color.Gray;
        myPane.YAxis.MajorGrid.Color = Color.Gray;
        myPane.XAxis.MajorGrid.DashOff = 0;
        myPane.YAxis.MajorGrid.DashOff = 0;

        // Move Legend to bottom
        myPane.Legend.Position = LegendPos.Bottom;

        zgc.AxisChange();

        myPane.XAxis.Scale.Max = MaxXAxis;

        zgc.Location = new Point(0, 0);
        zgc.Size = new Size(panel_diagramm.ClientRectangle.Width, panel_diagramm.ClientRectangle.Height);

        panel_diagramm.Controls.Add(zgc);


    }

How can i change the above two functions that they display the frequency in the x-axis?

I already tried to change the AddGraph-function to pass the needed parameters and to calculate the list to have the correct values. But what then...?

public void AddGraph_Frequency(int **Points**, double **StartFrequency**, 
double **StopFrequency**, double[] Values, string GraphColor, string LegendName)

{
...
double frequency = StartFrequency; //der erste Punkt
double Intervall = (StopFrequency - StartFrequency) / Points; 
for (i = 0; i < Points; i++)
{
    list.Add(frequency, Values[i]);
    frequency = frequency + Intervall;
}

....
}

Thanks for any help best regards

Thomas Mann
  • 99
  • 3
  • 19

1 Answers1

0

Solved. Missing was:

myPane.XAxis.Scale.Max = Stopfrequency;
myPane.XAxis.Scale.Min = Startfrequency;
Thomas Mann
  • 99
  • 3
  • 19