Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

zedgraph. two graphs, one above the other

$
0
0

I use zedgraph in my project, and i have a trouble. I have 2 graphs, they are located one above the other. See at the figure:

Look at the right border. Elements are not positioned one above the other.

I use MasterPane and PaneLayout.SingleColumn. I took the example from here (example) and slightly changed it to use bars.

Here is my code:

private void CreateGraph_ThreeVerticalPanes(ZedGraphControl z1)
        {
            MasterPane master = z1.MasterPane;
            master.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);
            master.PaneList.Clear();
            master.Title.IsVisible = true;
            master.Title.Text = "My data";
            master.Margin.All = 10;
            master.InnerPaneGap = 5;
            string[] yLabels = { "Graph-1", "Graph-2" };
            for (int j = 0; j < 2; j++)
            {
                GraphPane myPaneT = new GraphPane(new Rectangle(10, 10, 10, 10), "", "", yLabels[j]);
                myPaneT.Fill.IsVisible = false;
                myPaneT.Chart.Fill = new Fill(Color.White, Color.LightYellow, 45.0F);
                myPaneT.BaseDimension = 3.0F;
                myPaneT.Legend.IsVisible = false;
                myPaneT.Border.IsVisible = false;
                myPaneT.Title.IsVisible = false;
                myPaneT.XAxis.MajorTic.IsOutside = false;
                myPaneT.XAxis.MinorTic.IsOutside = false;
                myPaneT.XAxis.MajorGrid.IsVisible = true;
                myPaneT.XAxis.MinorGrid.IsVisible = true;
                myPaneT.Margin.All = 0;
                if (j == 0)
                {
                    myPaneT.Margin.Top = 20;
                    myPaneT.XAxis.Title.IsVisible = false;
                    myPaneT.XAxis.Scale.IsVisible = false;
                }
                if (j == 1)
                {
                    myPaneT.Margin.Bottom = 10;
                    myPaneT.YAxis.Scale.IsSkipLastLabel = true;
                }
                myPaneT.YAxis.MinSpace = 80;
                myPaneT.Y2Axis.MinSpace = 20;
                myPaneT.BarSettings.Type = BarType.Cluster;
                string[] labels = { "Position 1", "Position 2", "Position 3", "Position 4", "Position 5", "Position 6" };
                double[] y = { 95, 55, 75, 22, 98, 40 };
                double[] y2 = { 90, 45, 35, 15, 80, 35 };
                BarItem myBar = myPaneT.AddBar("Curve 1", null, y, Color.Red);
                myBar.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red);
                myBar = myPaneT.AddBar("Curve 2", null, y2, Color.Blue);
                myBar.Bar.Fill = new Fill(Color.Blue, Color.White, Color.Blue);
                myPaneT.XAxis.MajorTic.IsBetweenLabels = true;
                myPaneT.XAxis.Type = AxisType.Text;
                myPaneT.XAxis.Scale.TextLabels = labels;
                master.Add(myPaneT);
            }

            using (Graphics g = this.CreateGraphics())
            {
                master.SetLayout(g, PaneLayout.SingleColumn);
                master.AxisChange(g);
            }
            z1.AxisChange();
        }

How can I align the boundaries?


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>