2014-03-26 113 views
0

我有一个工作程序,我可以将数组添加到Zedgraph并在窗体中显示。 现在我只想改变X轴从点(0..400)到频率(9e3..6e9 Hz)的显示。 这里是我目前的工作职能:Zedgraph - 从点到频率更改X轴

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); 


    } 

我怎样才能改变他们显示x轴的频率上面两个功能呢?

我已经尝试改变AddGraph函数来传递所需的参数并计算列表以获得正确的值。但是,那么......?

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; 
} 

.... 
} 

感谢解决任何帮助 问候

回答

0

。 缺失:

myPane.XAxis.Scale.Max = Stopfrequency; 
myPane.XAxis.Scale.Min = Startfrequency;