无法让 zedgraph 工作

发布于 2024-12-27 11:38:15 字数 4432 浏览 1 评论 0原文

我尝试创建一种方法,在 zedgraph 中插入一些数字。但这是行不通的。 这是我的代码:

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

“consolewriteline”的输出是:0 15 56 4 9。因此我预计图表上至少有 4 个条形。但什么也没发生。希望有人知道.. 谢谢。

I've tried to make a method, which insert some numbers in a zedgraph. But it won't work.
This is my code:

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

The output from the "consolewriteline" is: 0 15 56 4 9. And therefor I expect at least 4 bars on the graph. But nothing happens. Hope anyone knows..
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫思念不要吵 2025-01-03 11:38:15
    PPLa.Add(h,aa);
    PPLa.Add(h, bb);
    PPLa.Add(h, cc);
    PPLa.Add(h, dd);
    PPLa.Add(h, ff);

需要:

    PPLa.Add(h,aa);
    PPLb.Add(h, bb);
    PPLc.Add(h, cc);
    PPLd.Add(h, dd);
    PPLe.Add(h, ff);

我希望这对你有用

    PPLa.Add(h,aa);
    PPLa.Add(h, bb);
    PPLa.Add(h, cc);
    PPLa.Add(h, dd);
    PPLa.Add(h, ff);

needs to be:

    PPLa.Add(h,aa);
    PPLb.Add(h, bb);
    PPLc.Add(h, cc);
    PPLd.Add(h, dd);
    PPLe.Add(h, ff);

i hope this will work for you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文