I am trying to get the x axis labels to wrap on a column chart (part of a composite chart) and the following does not work:
Dim wraptext As New WrapTextAxisLabelLayoutBehaviorwraptext.enabled = truewraptext.UseOnlyToPreventCollisions = False.AxisX.Labels.Layout.BehaviorCollection.Add(wraptext).AxisX.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.UseCollection
This is the result:
What am I doing wrong?
Thanks,
Dana
Looks like you're using series labels on your chart, so you should be setting the wrap text behavior to the seres labels, instead of item labels:Axis.X.Labels.SeriesLabels.Layout.BehaviorCollection.Add(wraptext)Axis.X.Labels.SeriesLabels.Layout.Behavior = UseCollectionAlso, it wouldn't hurt to set EnableRollback to false on the wrap text behavior itself.
Thanks. That does work if the EnableRollback is set to false AND there is enough axis extent to show the wrapped text.
On a related note, any way to stop it from breaking in the middle of a word? In otherwords, only split on spaces?
The wrap text behavior typically only breaks on spaces, but I can see how in some cases it can break in the middle of a word. There isn't an option to control how the string breaks up on the behavior, but if you want more control over this, you can implement IRenderLabel and break up the string manually. Here's an example of using IRenderLabel:http://help.infragistics.com/NetAdvantage/WinForms/2010.3/CLR2.0/?page=Chart_Customize_Labels_Using_the_IRenderLabel_Interface.htmlThere should also be plenty of other examples on these forums if you search for "IRenderLabel"