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,
I have spent some time investigating this issue for you. I have attached a sample project where I have used TranslateTransform in order to set location for the labels. In order to achieve that I have created a converter (LabelTranslateConverter) and I have used binding in order to bind the TextBlock of the Labels to xamDataChart. Then I use ScalerParams and TransformGroup in order to set the label to appear where you want. You could modify the location by changing the values for the Y axis and the angle of rotation. By using the Translate transform the textBlock will be rotated without cutting off its content and the elements will be arranged so that their content is visible.
Please feel free to let me know if you have any questions regarding this.
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.
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.