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
180
Chart Labels (Units)
posted

I had a few items.

I was looking for a way to add Axis Labels (or titles) that indicate units, but not the labels I see in the API.  For example, if I have a chart that tracks interest rates for mortgages over time, I might have a label called 'Mortgage Rate (%)' on the Y axis rotated 90 degrees, and a label called 'Month' for the X axis.  I don't see these axis labels part of the chart.

I was also trying to move the chart legend below the X axis of the chart instead of to the right of the chart.  Is there a way to do this?

Can you apply the axis labels to every other or every fifth line?

Parents
No Data
Reply
  • 28496
    Verified Answer
    Offline posted

    axis titles are not available as a feature of the XamChart.  however, you can put some TextBlocks in the ControlTemplate to get the results you're looking for.  the code below demonstrates this, as well as how to set the interval on an axis:

    <igChart:XamWebChart>
                <igChart:XamWebChart.Series>
                    <igChart:Series >
                        <igChart:Series.DataPoints>
                            <igChart:DataPoint Value="1" Label="A" />
                            <igChart:DataPoint Value="1" Label="B" />
                            <igChart:DataPoint Value="1" Label="C" />
                            <igChart:DataPoint Value="1" Label="D" />
                            <igChart:DataPoint Value="1" Label="E" />
                            <igChart:DataPoint Value="1" Label="F" />
                            <igChart:DataPoint Value="1" Label="G" />
                            <igChart:DataPoint Value="1" Label="H" />
                            <igChart:DataPoint Value="1" Label="I" />
                            <igChart:DataPoint Value="1" Label="J" />                       
                        </igChart:Series.DataPoints>
                    </igChart:Series>
                </igChart:XamWebChart.Series>
                <igChart:XamWebChart.Axes>
                    <igChart:Axis AxisType="PrimaryX" AutoRange="False" Minimum="0" Maximum="11" Unit="5" />
                </igChart:XamWebChart.Axes>
                <igChart:XamWebChart.Template>
                    <ControlTemplate TargetType="igChart:XamWebChart">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <Grid x:Name="RootElement" Background="{TemplateBinding Background}" Margin="{TemplateBinding Padding}" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <TextBlock Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Text="Y Axis Title" RenderTransformOrigin="0.5, 0.5" VerticalAlignment="Center" FontSize="14">
                                    <TextBlock.RenderTransform>
                                        <RotateTransform Angle="-90" />
                                    </TextBlock.RenderTransform>
                                </TextBlock>
                                <Grid x:Name="CaptionPanel" Grid.Row="0" Grid.Column="1" />
                                <Grid x:Name="ScenePanel" Grid.Column="1" Grid.Row="1"/>
                                <TextBlock Grid.Column="1" Grid.Row="2" Text="X Axis Title" HorizontalAlignment="Center" FontSize="14" />
                                <Grid x:Name="LegendPanel" Grid.Column="1" Grid.Row="3" />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </igChart:XamWebChart.Template>
            </igChart:XamWebChart>

Children