I know that I can change the orientation of the x axis series lables, but is there any way to alternate the vertical position of the labels when they are too wide to fit without overlapping? Below is an example of what I am trying to achieve:
set
xAxis.Labels.SeriesLabels.Layout.Behavior = UseCollection
then access xAxis.Labels.SeriesLabels.BehaviorCollection, and add a Stagger behavior to that collection. set EnableRollback = false and UseOnlyToPreventCollisions = false to force it to always stagger the labels.
I tried this solution, but no luck. Here is the code I am using. I'm sure you will quickly see what I am missing:
//Add a stagger behavior to the x axis labels
this.ultraChart1.Axis.X.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.UseCollection;
StaggerAxisLabelLayoutBehavior stagger = new StaggerAxisLabelLayoutBehavior();
stagger.Enabled = true;
stagger.EnableRollback = false;
stagger.UseOnlyToPreventCollisions = false;
this.ultraChart1.Axis.X.Labels.SeriesLabels.Layout.BehaviorCollection.Add(stagger);
Works perfectly. Thanks again!
I was premature when I said it worked perfectly. When I have an even number of column groups, the axis label for the last group does not display. If there is an even number, then it does display. See images below:
i did not experience this problem in my sample. it could be an issue that was fixed -- what is the complete 4-part version number of the chart dll you're using?
8.3.20083.2059
i was able to reproduce this problem, so i entered it as a bug ... # 16499.
it should be resolved in a future hotfix. feel free to contact Infragistics Developer Support at any time to inquire about the status of this bug. http://infragistics.com/gethelp
if you need a temporary workaround, try replacing the Stagger behavior you added with one of these:
internal class MyStaggerBehavior : StaggerAxisLabelLayoutBehavior { public override bool Apply(Rectangle bounds, IAdvanceAxis axis, AxisAppearance axisApp, AxisLabelInfoCollection labels, out Rectangle boundsUsed) { for (int current = 0; current < labels.Count; current++) { if (current % 2 == 1) { labels[current].TextPrimitive.bounds.Offset(0, 10); } SizeF labelSize = Infragistics.UltraChart.Core.Util.Platform.GetLabelSizePixels(labels[current].TextPrimitive.GetTextString(), labels[current].TextPrimitive.labelStyle); labels[current].TextPrimitive.bounds.Width = (int)Math.Ceiling(Math.Max(labelSize.Width, labels[current].TextPrimitive.bounds.Width)); } boundsUsed = bounds; return true; } }