DataTable tbl = new DataTable(); tbl.Columns.Add("Age",typeof(int)); tbl.Columns.Add("Value",typeof(double )); int lcount = 300; for( int i = 1; i<lcount; i++) { DataRow r= tbl.NewRow(); r["Age"]=i; r["Value"]=Math.Sin(3.14*i/100); tbl.Rows.Add( r); } chartForecasts.DataSource = tbl; chartForecasts.Data.RowLabelsColumn = 0; chartForecasts.Axis.X.TickmarkInterval = (int)lcount / 20; chartForecasts.DataBind(); chartForecasts.Visible = true;
Chart is simple 2D line chart.
If number of points is say 20 shows all X axis labels from column[0] of binded table , but after certain amount of datapoints labels dissapear. I tried to experimnt with TickmarkInterval but this does not help.
That is likely happening because of the automatic label collision avoidance. You can disable it by settingchart.Axis.X.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.None;
You can also use a BehaviorCollection to use some of the pre-defined methods of managing colliding labels. More info can be found here:http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/Chart_Axis_Label_Layout_Behaviors.html
I tried your suggestion.
In this case chart displays labels of wrong column (instead of column 0 it uses labels from column 1).
By the way is there a possibility to tell chart to plot just say first 100 rows from table?
DataTable tbl = new DataTable(); tbl.Columns.Add("Age",typeof(int)); tbl.Columns.Add("Value",typeof(double )); int lcount = 300; for( int i = 1; i<lcount; i++) { DataRow r= tbl.NewRow(); r["Age"]=i; r["Value"]=Math.Sin(3.14*i/100); tbl.Rows.Add( r); } dgForecasts.DataSource = tbl; chartForecasts.DataSource = tbl; //chartForecasts.Axis.X.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Percentage; //chartForecasts.Axis.X.TickmarkPercentage = 10; chartForecasts.Axis.X.Labels.Layout.Behavior = Infragistics.UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.None; //chartForecasts.Axis.X.Labels.Layout.Behavior = // Infragistics.UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.Auto; chartForecasts.Axis.X.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart; chartForecasts.Data.RowLabelsColumn = 0; chartForecasts.Data.UseRowLabelsColumn = true; chartForecasts.DataBind();
Unfortunately, there's no way to tell the chart to use only a part of the data table's rows. You can extract the rows to a new table or try creating a data view.I'm not entirely sure what you expect the chart to look like. I'm assuming you have set SwapRowsAndColumns property to true, otherwise every row of data will be a separate line.
When you bind to a table with 2 numeric columns, you should see 2 lines. Numeric values are plotted against the Y axis, data point indeces are plotted against the Y axis. If you don't want to plot the Age column, you can change its type to string. Try using something like this:DataTable tbl = new DataTable();tbl.Columns.Add("Age", typeof(string));tbl.Columns.Add("Value", typeof(double));int lcount = 300;for (int i = 1; i < lcount; i++){ DataRow r = tbl.NewRow(); r["Age"] = i; r["Value"] = Math.Sin(3.14 * i / 100); tbl.Rows.Add(r);}ultraChart1.Data.DataSource = tbl;ultraChart1.Data.SwapRowsAndColumns = true;ultraChart1.Axis.X.Labels.Orientation = TextOrientation.VerticalLeftFacing;ultraChart1.Axis.X.TickmarkInterval = 10;ultraChart1.Axis.X.TickmarkStyle = AxisTickStyle.DataInterval;ultraChart1.Axis.X.Labels.Layout.Behavior = Infragistics.UltraChart.Shared.Styles.AxisLabelLayoutBehaviors.None;
How obvious is that. Lets turn the axislablellayoutbehaviour from auto to none to be able to see any axis lablels.
I have just had the same problem and it has taken infragistics support five days and as many attempts to come up with the same suggestion. It would suggest that like every other graphing tool I have used, including mschart.ocx developed in the mid 90 circa vb6, that the intelegance in this control for label collision is sub standard.
Surley an sensible default algorithm is to reduce back the number of ticks/labels along the axis until they display without collision. A algorithm which decides to display none when clearly a dozen or more could be added is plain dumb.
The suggestion to turn the layoutbahaviour to none according to infragistics documentation : 'AxisLabelLayoutBehaviors.None -- Labels will not be prevented from overlapping or colliding' would apprear to suggest that all labels will be displayed and colide. There is no mention of which labels will be chosen to be displayed or the correlation to tickmarkinterval.
Please infragistics can you sort this one out.
the axis label layout behaviors don't selectively remove certain labels, they just attempt to reduce the font size, stagger the labels, rotate them, etc. to prevent collisions.
try setting Axis.X.TickmarkStyle = Smart to prevent collisions by selectively removing labels.
you can also set Axis.X.TickmarkStyle = DataInterval and Axis.X.TickmarkInterval = 5 to display every 5th label.