Hello *,
I need to display two charts one below the other, where the format and tickmarks of the axis-labels are customizable by the user.
actual:
|Axis1|Chart1|
|Axis2 with longer Labels|Chart2|
suggested:
| Axis1|Chart1|
|Axis2 with longer labels|Chart2|
Is there a simple way to sync the start of the chartareas or to sync the width of the axis-labels?
1. My actual sample is setting/resetting the AxisLabelSettings in codebehind but the axis labels did not have the default style applied. Can you please modify my sample in the way you have outlined in your last post?
1. The reason you are seeing a difference when removing the AxisLabelSettings in Xaml for your first chart is because we provide our own styles internally. Removing it intentionally will strip away the margin, font color etc. If you add a new AxisLabelSettings in code-behind to set the Extent property you will see the default behavior again. Keep in mind by excluding the AxisLabelSettings in XAML, you are nullifying the object and will get an exception if you attempt to reference it during code-behind. Therefore you must define an AxisLabelSetting object in code beforehand.
2. You need a flag and conditionally check when to set the extent, otherwise the code you want to fire will never happen when UpdateExtend is fired.
Hello Michael,
1. In the attached screenshot only for the first chart AxisLabelSettings(<ig:AxisLabelSettings/>) are set. As you can see font, font-color, margin and alignment are not the same on the charts. When you need to reproduce this behavior just remove the AxisLabelSettings of one of the charts in my previous attached sample!
2. If I do not set the Extend of the axis and push the ExpandLabel button in my sample the space of the axis is automatically expanded to fit the size of the labels. If I set the Extend this behavior is broken, so i need a way to go back to the default behavior. To reproduce this behavior just remove the event handle(RefreshCompleted="UpdateExtend") from the second chart in my sample and use the ExpandLabel buttton.
Hello Andreas,
Setting the Extent property should have no affect of other properties or default behavior. I ran you sample and noticed no difference in the margin or font. Can you please upload a screenshot illustrating the change in behavior.
There is no auto size method on the Axis object; you need to recalculate the extent back down to their default size manually. When you do you need to auto size?
As you have already suspected the code will look similar to this:
if (yAxis1.LabelSettings.Extent >= 119) { yAxis1.LabelSettings.Extent = 50; yAxis2.LabelSettings.Extent = 50; } else { yAxis1.LabelSettings.Extent = 119; yAxis2.LabelSettings.Extent = 119; }
Thanks again for your help.
The suggested solution works if the size of the labels is constant. In our application the labels can change because of new data added to the charts. (I think the same problem occurs when zooming is used.)
Is there a way to reset the labelsettings extend so that the LabelPanel will autosize(to fit the labels) again? I have attached a demo which contains a button to simulate changing labels.
Another noticeable behavior is that you have to specify
<ig:NumericYAxis.LabelSettings> <ig:AxisLabelSettings/> </ig:NumericYAxis.LabelSettings>
to be able to change the extend in code behind. Doing so applies other default settings to the AxisLabelSettings (e.g. Margin and Font). Is this an expected behavior? And how to apply the original default settings?