C# 无法使zedgraph正常工作
我尝试了一种方法,在zedgraph中插入一些数字。但这行不通。 这是我的代码:C# 无法使zedgraph正常工作,c#,winforms,visual-studio,zedgraph,C#,Winforms,Visual Studio,Zedgraph,我尝试了一种方法,在zedgraph中插入一些数字。但这行不通。 这是我的代码: string title = "Contemporary Quality"; string xaxis = "Amount"; string yaxis = "Percent"; zedGraphControl3.GraphPane.CurveList.Clear(); zedGraphControl3.GraphPane.GraphO
string title = "Contemporary Quality";
string xaxis = "Amount";
string yaxis = "Percent";
zedGraphControl3.GraphPane.CurveList.Clear();
zedGraphControl3.GraphPane.GraphObjList.Clear();
GraphPane myPane = zedGraphControl3.GraphPane;
myPane.GraphObjList.Clear();
myPane.CurveList.Clear();
myPane.XAxis.Title.Text = xaxis;
myPane.Title.Text = title;
myPane.YAxis.Title.Text = yaxis;
myPane.XAxis.Scale.MinAuto = false;
myPane.XAxis.Scale.MinGrace = -0.5;
myPane.XAxis.Scale.Max = 16;
myPane.BarSettings.Type = BarType.PercentStack;
double[] x = new double[] { zg1.GraphPane.XAxis.Scale.Min, zg1.GraphPane.XAxis.Scale.Max };
double[] y = new double[] { 20, 20 };
ZedGraph.LineItem lineItem = new ZedGraph.LineItem("cursorY1", x, y, Color.Black, ZedGraph.SymbolType.None);
lineItem.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
lineItem.IsSelectable = false;
lineItem.Label.IsVisible = false; // hides the cursor in the legend
zg1.GraphPane.CurveList.Add(lineItem);
y = new double[] { 40, 40 };
lineItem = new ZedGraph.LineItem("cursorY2", x, y, Color.Black, ZedGraph.SymbolType.None);
lineItem.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
lineItem.IsSelectable = false;
lineItem.Label.IsVisible = false; // hides the cursor in the legend
zg1.GraphPane.CurveList.Add(lineItem);
y = new double[] { 60, 60 };
lineItem = new ZedGraph.LineItem("cursorY3", x, y, Color.Black, ZedGraph.SymbolType.None);
lineItem.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
lineItem.IsSelectable = false;
lineItem.Label.IsVisible = false; // hides the cursor in the legend
zg1.GraphPane.CurveList.Add(lineItem);
y = new double[] { 80, 80 };
lineItem = new ZedGraph.LineItem("cursorY4", x, y, Color.Black, ZedGraph.SymbolType.None);
lineItem.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
lineItem.IsSelectable = false;
lineItem.Label.IsVisible = false; // hides the cursor in the legend
zg1.GraphPane.CurveList.Add(lineItem);
PointPairList PPLa = new PointPairList();
PointPairList PPLb = new PointPairList();
PointPairList PPLc = new PointPairList();
PointPairList PPLd = new PointPairList();
PointPairList PPLf = new PointPairList();
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int f = 0;
List<string> newlistString = new List<string>();
DateTime end = dateTimePicker2.Value.Date;
DateTime start = dateTimePicker1.Value.Date;
newlistString = ctrscan.AnalyzeOldScans(start, end);
for (int h = 0; h <= (newlistString.Count - 1); h++)
{
if (newlistString[h].Equals("A"))
{
a = a + 1;
}
if (newlistString[h].Equals("B"))
{
b = b + 1;
}
if (newlistString[h].Equals("C"))
{
c = c + 1;
}
if (newlistString[h].Equals("D"))
{
d = d + 1;
}
if (newlistString[h].Equals("F"))
{
f = f + 1;
}
double aa = Convert.ToDouble(a);
double bb = Convert.ToDouble(b);
double cc = Convert.ToDouble(c);
double dd = Convert.ToDouble(d);
double ff = Convert.ToDouble(f);
PPLa.Add(h,aa);
PPLa.Add(h, bb);
PPLa.Add(h, cc);
PPLa.Add(h, dd);
PPLa.Add(h, ff);
}
Console.WriteLine(a+" "+b+" "+c+" "+d+" "+f);
BarItem myBara = myPane.AddBar("Quality A", PPLa, Color.Red);
BarItem myBarb = myPane.AddBar("Quality B", PPLb, Color.Blue);
BarItem myBarc = myPane.AddBar("Quality C", PPLc, Color.Gray);
BarItem myBard = myPane.AddBar("Quality D", PPLd, Color.Black);
BarItem myBarf = myPane.AddBar("Quality F", PPLf, Color.Pink);
zedGraphControl3.AxisChange();
zg1.AxisChange();
string title=“当代品质”;
字符串xaxis=“金额”;
字符串yaxis=“百分比”;
zedGraphControl3.GraphPane.CurveList.Clear();
zedGraphControl3.GraphPane.GraphHobjList.Clear();
GraphPane myPane=zedGraphControl3.GraphPane;
myPane.GraphObjList.Clear();
myPane.CurveList.Clear();
myPane.XAxis.Title.Text=XAxis;
myPane.Title.Text=标题;
myPane.YAxis.Title.Text=YAxis;
myPane.XAxis.Scale.MinAuto=false;
myPane.XAxis.Scale.MinGrace=-0.5;
myPane.XAxis.Scale.Max=16;
myPane.BarSettings.Type=BarType.PercentStack;
double[]x=新的double[]{zg1.GraphPane.XAxis.Scale.Min,zg1.GraphPane.XAxis.Scale.Max};
double[]y=新的double[]{20,20};
ZedGraph.LineItem LineItem=新的ZedGraph.LineItem(“cursorY1”,x,y,Color.Black,ZedGraph.SymbolType.None”);
lineItem.Line.Style=System.Drawing.Drawing2D.DashStyle.Dash;
lineItem.IsSelectable=false;
lineItem.Label.IsVisible=false;//在图例中隐藏光标
zg1.图形平面.曲线列表.添加(行项目);
y=新的双[]{40,40};
lineItem=新的ZedGraph.lineItem(“cursorY2”,x,y,Color.Black,ZedGraph.SymbolType.None);
lineItem.Line.Style=System.Drawing.Drawing2D.DashStyle.Dash;
lineItem.IsSelectable=false;
lineItem.Label.IsVisible=false;//在图例中隐藏光标
zg1.图形平面.曲线列表.添加(行项目);
y=新的双[]{60,60};
lineItem=新的ZedGraph.lineItem(“cursorY3”,x,y,Color.Black,ZedGraph.SymbolType.None);
lineItem.Line.Style=System.Drawing.Drawing2D.DashStyle.Dash;
lineItem.IsSelectable=false;
lineItem.Label.IsVisible=false;//在图例中隐藏光标
zg1.图形平面.曲线列表.添加(行项目);
y=新的双[]{80,80};
lineItem=新的ZedGraph.lineItem(“光标4”,x,y,Color.Black,ZedGraph.SymbolType.None);
lineItem.Line.Style=System.Drawing.Drawing2D.DashStyle.Dash;
lineItem.IsSelectable=false;
lineItem.Label.IsVisible=false;//在图例中隐藏光标
zg1.图形平面.曲线列表.添加(行项目);
PointPairList PPLa=新的PointPairList();
PointPairList PPLb=新的PointPairList();
PointPairList PPLc=新的PointPairList();
PointPairList PPLd=新的PointPairList();
PointPairList PPLf=新的PointPairList();
int a=0;
int b=0;
int c=0;
int d=0;
int f=0;
List newlistString=新列表();
DateTime end=dateTimePicker2.Value.Date;
DateTime start=dateTimePicker1.Value.Date;
newlistString=ctrscan.AnalyzeOldScans(开始、结束);
对于(int h=0;h
需要:
PPLa.Add(h,aa);
PPLb.Add(h, bb);
PPLc.Add(h, cc);
PPLd.Add(h, dd);
PPLe.Add(h, ff);
我希望这对您有用我也尝试过移动“plla.add”方法在循环之外,这也不起作用。您只使用值填充PPLa,这需要更改,PPLb等可能也填充了SOOMG,这太差劲了。无论如何,谢谢!哪一个没有显示?zg1或zg3?也。查看PPLa-e以检查这是否填充正确。如果没有,您需要查看代码的填充部分。以及另一个also、 将myPane.Bar设置为正常,以查看是否有任何工作
PPLa.Add(h,aa);
PPLb.Add(h, bb);
PPLc.Add(h, cc);
PPLd.Add(h, dd);
PPLe.Add(h, ff);