We have a chart with a numeric Y axis and a Category X axis and a column Series of data. We need to produce a Bar Chart (A histogram) BUT we need the X Axis labels to appear at the category breaks and not centered under the category bar.
This is relativly simple if you have a fixed number of categories and a fixed chart size using transforms and transform origin in the label datatemplate BUT... Our users can dynamically change the number of categories and resize the screen. Any idea how we can accomplish this? How do I know the width of the label as it does not honor the "Stretch" attribute and grow/shrink with the label width.
<ig:CategoryXAxis.Label>
<DataTemplate>
<!--Text="{Binding Item.EndX}"-->
<TextBlock VerticalAlignment="Stretch" HorizontalAlignment="Stretch" RenderTransformOrigin="0,0">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource Axis_DisplayUnitsMultiConverterInstance}">
<Binding Path="Item.EndX" />
<Binding Path="Axis.DataContext.XAxis"/>
</MultiBinding>
</TextBlock.Text>
<TextBlock.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="90" />
<TranslateTransform Y="90" />
</TransformGroup>
</TextBlock.LayoutTransform>
</TextBlock>
</DataTemplate>
</ig:CategoryXAxis.Label>
thanks
Hello Rod,
Thank you for contacting our community.
I have been looking through your post and I am not sure that I understand your scenario correctly. Could you attach a picture of what you are trying to achieve so that I could provide you with a better solution?
If you are trying to apply a DataTemplate to all the CategoryXAxis’ labels in the XamDataChart, you could use a style for the CategoryXAxis and set its label property like it is done in the code below:
<Style TargetType="{x:Type ig:CategoryXAxis}">
<Setter Property="Label">
<Setter.Value>
</Setter.Value>
</Setter>
</Style>
I am looking forward for your reply.
OK - I cant get the Insert Image to work - so details are embedded in a zipped word document.
Essentially I need to move the label to the right so it is between the categories not centered under the category , also having it angled at a 45 would be nice but it gets cut off.