Hello
I have a chart based on an OlapXAxis. This work overall fine, but my challenge is that I want to rotate the labels on the X axis. The reason for that is I sometimes have many rows on the X-axis and the labels overlaps. Rotateing them will generate more space
What I done so far:
Set a LabelStyle on the axis.
x:Name="olapXAxis" OlapAxisSource="Rows" YAxis="{Binding ElementName=xmYAxis1}" LabelStyle="{StaticResource OlapLabelControlStyle}">
The Style:
<Style TargetType="ig:OlapLabelControl" x:Key="OlapLabelControlStyle">
<Setter Property="Foreground" Value="Black" />
<Setter Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="90" />
</Setter.Value>
</Setter>
</Style>
I tried to change various margins and height, but nothing seems to work.This will rotate the text. But my problem is that the control does not resize and only the first few letters is shown, the rest is cut off (see attached file)
Any suggestions or alternative ways to do it?
Hi Rob
I am afraid this still causing some trouble for me.
If I first add a row with the lengt 20 the label formats fine. But if I remove the label and add another of length 3, it will still have the a big size.
Any suggestions?
Thanks for your reply.
I agree- it is an odd way i've done it. But as you mention, the OlapXAxis.LabelSettings does not work for this type of axis, so I was already working on a workaround. And with the addition of your code, it work beautifully:)
It would be nice if the OlapXAxis.LabelSettings couldbe fixed. You example still have some minor issues, e.g. if you set the angle to 50 it is not working. But for now it is sufficient.
Hi logimatic,
I wouldn't say this is one of the correct ways to rotate the labels but it definitely seems weird that the chart is not resizing properly to account for the rotated OlapLabelControl. Normally the correct approach would be to set the OlapXAxis.LabelSettings.Angle property to the desired angle but this doesn't appear to be working correctly for OlapXAxis like it does with other axis types. I logged a development issue for this so our engineers can investigate. The dev issue ID is 229381.
I also created a private support case for you so that you can track the status of this dev issue. The case number is CAS-179285-Z6S9K2 and you can view it here. In the mean time you can use a workaround which I have attached to this post.
The workaround consists of setting up an attached property on the XamDataChart which then finds the OlapLabelPanelHorizontal element in the visual tree and hooks up to its SizeChanged event. When the SizeChanged event fires, it updates another attached property on the XamDataChart with the actual height value. I then bind the AxisLabelSettings.Extent property to the XamDataChart and the actual height attached property. So now whenever the height of the panel changes, it will update that attached property and update the Extent which will adjust the panel area height accordingly.
Let me know if you have any questions.