private void CreateGraph(ZedGraphControl zg1, string[] labels, double[] values) { // get a reference to the GraphPane GraphPane myPane = zg1.GraphPane; // Set the Titles myPane.Title = "My Test Bar Graph"; myPane.XAxis.Title = "Label"; myPane.YAxis.Title = "My Y Axis"; myPane.CurveList.Clear(); // Generate a red bar with "Curve 1" in the legend BarItem myBar = myPane.AddBar("Hits", null, values, Color.Red); myBar.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red); // Set the XAxis labels myPane.XAxis.Scale.TextLabels = labels; myPane.XAxis.Type = AxisType.Text; // Tell ZedGraph to refigure the // axes since the data have changed zg1.AxisChange(); zg1.ZoomOutAll(myPane); }
private void chart1_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { if (mouseDownLoc.IsEmpty || mouseUpLoc.IsEmpty) { return; } // if zoom rectangle is drawn from right to left, clear all zooming if (mouseDownLoc.X > mouseUpLoc.X && mouseDownLoc.Y > mouseUpLoc.Y ) { sender.ZoomOutAll(sender.GraphPane); RefreshChart(sender); } }