woojja Posted January 28, 2008 Report Share Posted January 28, 2008 a Below snippet is Realtime Sample code and i modifed code for my application. But i can't use Scroll mode. i want to use Just Scroll mode. and On Time, i want to print "DateTime.Now" Time on Axis X. how can i use Scroll mode? help me... plz. thank you for your read. ^^' and i waiting for your help... ^^ have a nice day. ############################################################33 private void Form1_Load(object sender, EventArgs e) { // Initialize background image Bitmap bitmap = (Bitmap)Properties.Resources.BackgroundImage; backgroundImage = new ImageBackground(); backgroundImage.Image = bitmap; chart1.PlotAreaBackground = backgroundImage; // Removing this flag is required to support Fast Scroll chart1.ExtraStyle &= ~ChartStyles.CacheImage; // Set Real-Time settings chart1.Data.Series = 5; chart1.Data.Points = nTotalPoints; chart1.RealTime.BufferSize = nTotalPoints; chart1.RealTime.Mode = RealTimeMode.Loop; //==> (I want to change just "Scroll" mode but if i change mode to Scroll, i met a Below Error ) chart1.RealTime.LoopMarker.Color = Color.Red; // Set chart cosmetic settings chart1.Series[0].Color = Color.Red; chart1.Series[0].Line.Width = 2; chart1.AxisX.Grids.Major.Visible = false; chart1.Highlight.Enabled = false; chart1.AxisX.Min = 0; //chart1.AxisX.LabelsFormat.CustomFormat = "0.0 s"; chart1.AxisX.ScaleUnit = 40.0; chart1.AxisX.LabelsFormat.Decimals = 1; chart1.AxisX.Step = 60; // This will improve chart startup time as it will not wait until th data is initialized to draw the chart chart1.UpdateSizeNow(); // Initialize heatbeat related variables heartBeatfactor = 1; pointCount = 0; offset = 2.15; forceR = false; timer1.Stop(); //i don't like this code...and... isRunning = false; for(int i=0; i<nTotalPoints; i++) { timer1_Tick(null, null); } //while (pointCount <= nTotalPoints); timer1.Start(); isRunning = true; } bool isRunning = false; private void timer1_Tick(object sender, EventArgs e) { if (pointCount < nTotalPoints) { pointCount++; } else { if (pointCount == nTotalPoints) { if (radioButton4.Checked) chart1.RealTime.Mode = RealTimeMode.Scroll; pointCount++; } } chart1.Data[0, 0] = 2.1; chart1.RealTime.BeginAddData(1, RealTimeAction.Append); //this code too. if (isRunning) { for (int j = 1; j < 5; j++) { Random rrr = new Random(); chart1.Data[j, 0] = rrr.Next(2, 4) * 1.1 + DateTime.Now.Second * 0.01 * j; } chart1.Data.Labels[0] = (DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } else { chart1.Data.Labels.Add(""); } chart1.RealTime.EndAddData(radioButton4.Checked, true); } ######################################################################### these are Error message... System.ArgumentOutOfRangeException was unhandled Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index" Source="mscorlib" ParamName="index" StackTrace: at System.Collections.ArrayList.get_Item(Int32 index) at ChartFX.WinForms.Internal.RequiresAmbientCollection.get_Item(Int32 index) at ChartFX.WinForms.LabelCollection.get_Item(Int32 index) at ChartFX.WinForms.LabelCollection.b(Int32 A_0) at ChartFX.WinForms.LabelAwareCollection.a(IGraphicsEx A_0, Font A_1) at ChartFX.WinForms.LabelAwareCollection.a(IGraphicsEx A_0, Font A_1, Boolean A_2, Boolean& A_3) at ChartFX.WinForms.Axis.a(IGraphicsEx A_0, Boolean A_1, Size& A_2) at ChartFX.WinForms.Axis.a(ScaleInfoBase A_0, IGraphicsEx A_1, Boolean A_2, Rectangle[] A_3) at ChartFX.WinForms.Axis.a(ScaleInfoBase A_0, IGraphicsEx A_1) at ChartFX.WinForms.Axis.a(ScaleInfoBase A_0, IGraphicsEx A_1, Rectangle& A_2, RepaintFlags A_3) at ChartFX.WinForms.AxisCollection.a(ScaleInfoBase A_0, IGraphicsEx A_1, RepaintFlags A_2, Rectangle& A_3) at ChartFX.WinForms.ap.a(aw A_0) at ChartFX.WinForms.ap.b(aw A_0) at ChartFX.WinForms.ap.b(IGraphicsEx A_0, Rectangle& A_1, Boolean A_2) at ChartFX.WinForms.ap.a(IGraphicsEx A_0, Boolean A_1, Rectangle& A_2) at ChartFX.WinForms.Chart.a(IGraphicsEx A_0, Boolean A_1, Rectangle& A_2) at ChartFX.WinForms.Chart.b(IGraphicsEx A_0, Boolean A_1) at ChartFX.WinForms.Chart.a(IGraphicsEx A_0, Boolean A_1, Rectangle A_2) at ChartFX.WinForms.Axis.get_ScrollSize() at ChartFX.WinForms.RealTimeSettings.EndAddData(Boolean scrollLabels, Boolean scrollToEnd) at RealTime_Charts.Form11.timer1_Tick(Object sender, EventArgs e) in C:\Program Files\Chart FX for Visual Studio 2005\Help and Samples\Sample Applications\Windows Forms\RealTimeCharts\Form11.cs:line 117 at RealTime_Charts.Form11.Form1_Load(Object sender, EventArgs e) in C:\Program Files\Chart FX for Visual Studio 2005\Help and Samples\Sample Applications\Windows Forms\RealTimeCharts\Form11.cs:line 72 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at RealTime_Charts.Program.Main() in C:\Program Files\Chart FX for Visual Studio 2005\Help and Samples\Sample Applications\Windows Forms\RealTimeCharts\Program.cs:line 16 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() ############################################################################################# Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.