Share

ZedGraph

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Problems with Graph height in masterpane

You are viewing a single message from this topic. View all messages.

  1. 2009-03-07 19:54:05 UTC
    Hi,
    I am having some problems using masterpane and then defining graph height for some of my graphs.
    I have 3 or 4 graphs and I used a masterpane, but they were too small, I wanted to make it bigger.

    My code is this (I am trying to do it with the tutorial I got in the wiki):
    private void CreateGraph(ZedGraphControl zgc)
    {
    // First, clear out any old GraphPane's from the MasterPane collection
    MasterPane master = zgc.MasterPane;
    master.PaneList.Clear();

    // Display the MasterPane Title, and set the outer margin to 10 points
    master.Title.IsVisible = true;
    master.Title.Text = "My MasterPane Title";
    master.Margin.All = 10;

    // Create some GraphPane's (normally you would add some curves too
    GraphPane pane1 = new GraphPane();
    GraphPane pane2 = new GraphPane();
    GraphPane pane3 = new GraphPane();
    GraphPane pane4 = new GraphPane();
    GraphPane pane5 = new GraphPane();

    //-----
    // Set the Titles

    pane1.Title.Text = "My Test Graph\n(For CodeProject Sample)";
    pane1.XAxis.Title.Text = "My X Axis";
    pane1.YAxis.Title.Text = "My Y Axis";

    // Make up some data arrays based on the Sine function

    double x, y1, y2;
    PointPairList list1 = new PointPairList();
    PointPairList list2 = new PointPairList();
    for (int i = 0; i < 36; i++)
    {
    x = (double)i + 5;
    y1 = 1.5 + Math.Sin((double)i * 0.2);
    y2 = 3.0 * (1.5 + Math.Sin((double)i * 0.2));
    list1.Add(x, y1);
    list2.Add(x, y2);
    }

    // Generate a red curve with diamond

    // symbols, and "Porsche" in the legend

    LineItem myCurve = pane1.AddCurve("Porsche",
    list1, Color.Red, SymbolType.Diamond);

    // Generate a blue curve with circle

    // symbols, and "Piper" in the legend

    LineItem myCurve2 = pane1.AddCurve("Piper",
    list2, Color.Blue, SymbolType.Circle);

    //-----
    RectangleF rectVolumeNew = new RectangleF(100, 100, 1000, 1000);
    RectangleF rectVolumeNew2 = new RectangleF(50, 50, 2000, 2000);


    // Add all the GraphPanes to the MasterPane
    master.Add(pane1);
    //master.Add(pane2);
    //master.Add(pane3);
    //master.Add(pane4);
    //master.Add(pane5);

    // Refigure the axis ranges for the GraphPanes
    zgc.AxisChange();

    pane1.Chart.Rect = rectVolumeNew;
    // Layout the GraphPanes using a default Pane Layout
    using (Graphics g = this.CreateGraphics())
    {
    zedGraphControl1.MasterPane.PaneList[0].ReSize(g, rectVolumeNew);
    master.ReSize(g, rectVolumeNew2);
    //master.SetLayout(g, PaneLayout.SingleColumn);
    }
    }

    In this example, I have 1 graph in a masterpane, and I changed the height.
    The problem is: my graph is bigger then the "Rectangle" that the masterpane "gave" to it and the masterpane itself. So the masterpane doesn't grow and doesn't enlarge the graph's rectangle, the result is the following:

    [IMG]http://img.photobucket.com/albums/v21/oscar/Unbenannt-2.jpg[/IMG]

    The graph isn't finished. How can I fix that?

    Thank you,
    Oscar
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.