【问题标题】:ZedGraph How To Create a Classic Line Chart With XAxis.Type = AxisType.TextZedGraph 如何使用 XAxis.Type = AxisType.Text 创建经典折线图
【发布时间】:2015-04-16 13:38:32
【问题描述】:

我正在尝试使用 zed 图创建折线图。我只是想问一下,我怎样才能创建一个 XAxis 类型为 text 而 YAxis 类型为 doubles 的折线图。

首先我真的在搜索这个主题,但我没有得到任何结果。因为其他折线图总是关于 XAxis 上的日期和时间。我不需要 XAxis 上的日期和时间。我将使用 XAxis 的标签来命名 YAxis 上的点。

Here an Example Graph

            string[] labels = { "P(A)", "P(A)+P(T)", "P(A)+P(T)+P(G)", "P(A)+P(T)+P(G)+P(C)" };
    double[] y = { PA(), PA() + PT(), PA() + PT() + PG(), PA() + PT() + PG() + PC() };

    LineItem myLine = myPane.AddCurve("dizi 1", null, y, Color.Red);
    myLine.Line.Fill = new Fill(Color.Red, Color.White, Color.Red);

    myPane.XAxis.Scale.TextLabels = labels;
    myPane.XAxis.Type = AxisType.Text;

    myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
    myPane.Fill = new Fill(Color.FromArgb(250, 250, 255));
    zedGraphControl1.AxisChange();

****代码在上面。有什么问题吗?****

【问题讨论】:

    标签: c# charts linechart zedgraph linegraph


    【解决方案1】:

    我刚刚想通了!

    这里是创建基本折线图的示例代码!

            private void button3_Click(object sender, EventArgs e)
        {
            // generate some fake data
            double[] y = { 1, 2, 3, 9 ,1,15,3,7,2};
            string[] schools = { "A", "B", "C", "D" ,"E","F","G","H","J"};
    
            //generate pane
            var pane = zg1.GraphPane;
    
    
            pane.XAxis.Scale.IsVisible = true;
            pane.YAxis.Scale.IsVisible = true;
    
            pane.XAxis.MajorGrid.IsVisible = true;
            pane.YAxis.MajorGrid.IsVisible = true;
    
            pane.XAxis.Scale.TextLabels = schools;
            pane.XAxis.Type = AxisType.Text;
    
    
            //var pointsCurve;
    
            LineItem pointsCurve = pane.AddCurve("", null, y, Color.Black);
            pointsCurve.Line.IsVisible = true;
            pointsCurve.Line.Width = 3.0F;
             //Create your own scale of colors.
    
            pointsCurve.Symbol.Fill = new Fill(new Color[] { Color.Blue, Color.Green, Color.Red });
            pointsCurve.Symbol.Fill.Type = FillType.Solid;
            pointsCurve.Symbol.Type = SymbolType.Circle;
            pointsCurve.Symbol.Border.IsVisible = true;
    
    
    
            pane.AxisChange();
            zg1.Refresh();
            this.Controls.Add(zg1);
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-14
      • 2022-06-13
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      相关资源
      最近更新 更多