Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Zedgraph横穿条形图的水平线_C#_Graph_Bar Chart_Zedgraph - Fatal编程技术网

C# Zedgraph横穿条形图的水平线

C# Zedgraph横穿条形图的水平线,c#,graph,bar-chart,zedgraph,C#,Graph,Bar Chart,Zedgraph,我用的是ZedGraph 我想画垂直条,然后在整个绘图区域画一条水平线 它似乎只到了酒吧的尽头 我试图添加一些x轴和y轴的值来达到这个效果,但没有效果 可能吗 这是我的密码: private void CreateGraph( ZedGraphControl zgc ) { // get a reference to the GraphPane GraphPane myPane = zg1.GraphPane; // Set

我用的是ZedGraph

我想画垂直条,然后在整个绘图区域画一条水平线

它似乎只到了酒吧的尽头

我试图添加一些x轴和y轴的值来达到这个效果,但没有效果

可能吗

这是我的密码:

    private void CreateGraph( ZedGraphControl zgc )
    {
        // get a reference to the GraphPane
        GraphPane myPane = zg1.GraphPane;

        // Set the Titles
        myPane.Title.Text = "My Test Bar Graph";
        myPane.XAxis.Title.Text = "Label";
        myPane.YAxis.Title.Text = "My Y Axis";

        // Make up some random data points
        string[] labels = { "Panther", "Lion" };
        double[] y = { 100, 115 };
        double[] x = {0, 900 };
        double[] y4 = { 90, 90};

        // Generate a black line with "Curve 4" in the legend
        LineItem myCurve = myPane.AddCurve("Curve 4", x, y4, Color.Black, SymbolType.Circle);

        // Generate a red bar with "Curve 1" in the legend
       BarItem myBar = myPane.AddBar("Curve 1", null, y, Color.Red);
       myBar.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red);

        // Fix up the curve attributes a little
        myCurve.Symbol.Size = 8.0F;
        myCurve.Symbol.Fill = new Fill(Color.White);
        myCurve.Line.Width = 2.0F;

        // Fix up the curve attributes a little
        myCurve.Symbol.Size = 8.0F;
        myCurve.Symbol.Fill = new Fill(Color.White);
        myCurve.Line.Width = 2.0F;

        // Draw the X tics between the labels instead of 
        // at the labels
        myPane.XAxis.MajorTic.IsBetweenLabels = true;

        // Set the XAxis labels
        myPane.XAxis.Scale.TextLabels = labels;
        // Set the XAxis to Text type
        myPane.XAxis.Type = AxisType.Text;

        // Fill the Axis and Pane backgrounds
        myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
        myPane.Fill = new Fill(Color.FromArgb(250, 250, 255));

        // Tell ZedGraph to refigure the
        // axes since the data have changed
        zg1.AxisChange();
    }

我发现你不能只在条形图上画一条水平线,因为这种情况下的x轴类型不是数字/离散的-它是一个文本值

如果要在条形图上画水平线,必须使用组合图:

这样,x轴是数字轴,因此您可以创建所需的任何线条以及条形图