Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1886
Column Series - Category Axis and Label Location
posted

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

 

Parents
No Data
Reply
  • 17475
    Offline posted

    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>

                                <DataTemplate>

                                    <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>

                            </Setter.Value>

                        </Setter>

                    </Style> 

    I am looking forward for your reply.

Children