Ravindra Posted June 27, 2008 Report Share Posted June 27, 2008 The following code is used to plot some random data on chart with DateTime as X.Axis Labels When I click on Zoom button and dragged the ZoomRectangle to some extent, and then When I click on print preview button , print preview window is producing 100+ pages. and the plot in print preview window is not matching with the chart plot. Following is the code written by me for this operation... public partial class Form1 : Form { double[] dblData = new double[300]; DateTime[] dblDateTime = new DateTime[300]; List<Array> lstArray = new List<Array>(); ListProvider lsListProvider = new ListProvider(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { cfxChart.Data.Clear(); PlotData(); cfxChart.Data.Series++; cfxChart.AxisX.LabelsFormat.CustomFormat = "hh:mm:ss\n dd/MM/yyyy"; cfxChart.AxisX.Step = 0.000001; cfxChart.AxisX.MinorStep = 0.000000001; lstArray.Add(dblData); lstArray.Add(dblDateTime); lsListProvider.List = lstArray; cfxChart.DataSource = lsListProvider; cfxChart.Series[0].MarkerShape = MarkerShape.None; cfxChart.UserZoom += new EventHandler(cfxChart_UserZoom); cfxChart.AxisY.Min = 70; cfxChart.AxisY.Max = 80; } void cfxChart_UserZoom(object sender, EventArgs e) { cfxChart.AxisY.ZoomOff(); cfxChart.AxisY.Min = 70; cfxChart.AxisY.Max = 80; } private void tsbtnRefresh_Click(object sender, EventArgs e) { } private void tsbtnZoomIn_Click(object sender, EventArgs e) { cfxChart.Zoom = true; } private void tsbtnZoomOut_Click(object sender, EventArgs e) { cfxChart.Zoom = false; } private void tsbtnPrintPreview_Click(object sender, EventArgs e) { cfxChart.Printer.PrintPreview(); } private void tsbtnPrint_Click(object sender, EventArgs e) { cfxChart.Printer.PrintDialog(true); } private void PlotData() { DateTime dtNow = DateTime .Now ; int i = 0; Random r = new Random (); while (i < 100) { dblData = r.Next(75,80); dtNow = dtNow.AddMilliseconds(10); dblDateTime = dtNow; i++; } while (i < 200) { dblData = 1E+108; dtNow = dtNow.AddMilliseconds(10); dblDateTime = dtNow; i++; } while (i < 300) { dblData = r.Next(75, 80); dtNow = dtNow.AddMilliseconds(10); dblDateTime = dtNow; i++; } } } Thanks & Regards Ravindranath Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.