0

I am trying to create a visual representation of my data, I have already populated point pair lists and I am creating my chart as follows:

public void CreateChart(ZedGraphControl zgc)
    {
        GraphPane myPane = zgc.GraphPane;

        //set the title and axis labels
        myPane.Title.Text = "Graph";
        myPane.XAxis.Title.Text = "Width";
        myPane.YAxis.Title.Text = "Height";


        //create curves
        BarItem myCurve = myPane.AddBar("1", pointPairList1, Color.Blue);
        BarItem myCurve2 = myPane.AddBar("2", pointPairList2, Color.Red);

        zgc.AxisChange();

    }

When I call the method CreateChart(chart1) no changes are made to the graph, even the titles dont get updated.. Can anyone spot my mistake?

ANSWER:

        chart1.AxisChange();
        chart1.Invalidate();
        chart1.Refresh();
Silvia Stoyanova
  • 271
  • 2
  • 6
  • 20

2 Answers2

2

try

    zgc.refresh();

or

    zgc.invalidate();
koponk
  • 452
  • 1
  • 3
  • 14
0

Create an event ZedGraphWeb1_RenderGraph then put all you code inside that block.

Freddie Fabregas
  • 1,162
  • 1
  • 7
  • 17