prcunningham Posted May 18, 2009 Report Share Posted May 18, 2009 If I am using a datatable as my source, how do I identify the x axis. Quote Link to comment Share on other sites More sharing options...
TatianaG Posted May 18, 2009 Report Share Posted May 18, 2009 Please try the following code: DataTable dt = new DataTable();DataColumn dc1 = new DataColumn();dc1.ColumnName = "X";dc1.DataType = Type.GetType("System.Int32");DataColumn dc2 = new DataColumn();dc2.ColumnName = "Y";dc2.DataType = Type.GetType("System.Int32");dt.Columns.Add(dc1);dt.Columns.Add(dc2);...... DataTableProvider data = new ChartFX.WebForms.DataProviders. DataTableProvider (dt); chart1.DataSourceSettings.Fields.Add( new FieldMap ( "X" , FieldUsage .XValue)); //Setting X axis chart1.DataSourceSettings.Fields.Add( new FieldMap ( "Y" , FieldUsage .Value)); //Setting series chart1.DataSource = data; Quote Link to comment Share on other sites More sharing options...
prcunningham Posted May 18, 2009 Author Report Share Posted May 18, 2009 that works but there is still a problem. I have multiple series and I am using allowdrag. when i do it your way if I drag values from any series other that the first series everything disappears except the point that I dragged. Quote Link to comment Share on other sites More sharing options...
TatianaG Posted May 18, 2009 Report Share Posted May 18, 2009 Can you please send me a little sample code of how are you populating the chart? Because I also have AllowDrag activated and it doesn't seem to be any problem. Quote Link to comment Share on other sites More sharing options...
prcunningham Posted May 18, 2009 Author Report Share Posted May 18, 2009 This my code. How do I attach a image? I tried dragging on the default data thats loaded when the chart first comes up and it did the same thing. dt = New DataTable("Test") Dim cols() As String = {"Total Time", "Time", "Bot Temp", "Pressure", "Top Temp", "MFC4", "Argon", "ArN2", "Vent"}For Each col As String In cols dt.Columns.Add(col, Type.GetType( "System.Single")) Next cfx.Series.Clear() cfx.DataSourceSettings.Fields.Add(New FieldMap("Total Time", FieldUsage.XValue)) For Each dc As DataColumn In dt.ColumnsIf Not dc.ColumnName.Equals("Total Time") Then cfx.DataSourceSettings.Fields.Add(New FieldMap(dc.ColumnName, FieldUsage.Value)) Nextcfx.DataSourceSettings.DataSource = New DataTableProvider(dt) Quote Link to comment Share on other sites More sharing options...
prcunningham Posted May 18, 2009 Author Report Share Posted May 18, 2009 It only does it with the default data if it is set to gallery type X vs Y Quote Link to comment Share on other sites More sharing options...
TatianaG Posted May 18, 2009 Report Share Posted May 18, 2009 The way to achieve what you want is by processing the DataChangedByUser event as follows: private void chart1_DataChangedByUser (object sender,PointLabelEventArgs e) { if (e.Axis == chart1.AxisX) e.Handled = true; // Prevent change of X-Axis values } Please try it and let me know if it works for you. Quote Link to comment Share on other sites More sharing options...
prcunningham Posted May 19, 2009 Author Report Share Posted May 19, 2009 That was it. Thank you very much. For future reference where would I have found that information? 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.