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?
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>
Hi David,
I need to change the text of these axis titles (textblock) dynamically based on the drop down on my page. I tried to get the reference of these textblock using following line.
xamWebChart1.FindName("yAxisTitle") as TextBlock;
but it always return null. Kindly note that I have given the name to textblock like this
<Grid x:Name="CaptionPanel" Grid.Row="0" Grid.Column="1" /> <TextBlock x:Name="yAxisTitle" 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>
Anyway to change the title of Axis dynamically (in code behind file)? Your prompt response will be highly appreciated. Thanks
if you handle the loaded event of the element in the Template, you can get a reference to it in codebehind.
<TextBlock x:Name="yAxisTitle" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Text="Y Axis Title" RenderTransformOrigin="0.5, 0.5" VerticalAlignment="Center" FontSize="14" Loaded="yAxisTitle_Loaded">
private TextBlock yAxisTitle { get; set; } private void yAxisTitle_Loaded(object sender, RoutedEventArgs e) { this.yAxisTitle = sender as TextBlock; }