This is a migrated thread and some comments may be shown as answers.

Multi-line chart title where each line has different formatting

1 Answer 69 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 07 Jun 2012, 10:00 AM
Hi,

I want to have a 2 line title for my chart where each line has different formatting.  To illustrate:

Chart Title Line 1 (Bold and Font Size 16)
Chart Title Line 2 (Normal and Font Size 12)

Is this possible in the Silverlight RadChart control and if so, how do I go about doing this.

Thanks,

Tony

1 Answer, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 12 Jun 2012, 11:12 AM
Hi Tony,

You can achieve this by modifying the ControlTemplate of your ChartTitle. Here you can find the the style of the ChartTitle. I suggest that you modify the ControlTemplate like this:

<Style x:Key="ChartTitleStyle" TargetType="telerik:ChartTitle">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="telerik:ChartTitle">
                <Border BorderBrush="{TemplateBinding OuterBorderBrush}"
                BorderThickness="{TemplateBinding OuterBorderThickness}">
                    <Border Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}">
                        <StackPanel>
                            <ContentControl FontFamily="{TemplateBinding FontFamily}"
                                FontSize="{TemplateBinding FontSize}"
                                FontStyle="{TemplateBinding FontStyle}"
                                FontWeight="{TemplateBinding FontWeight}"
                                Foreground="{TemplateBinding Foreground}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                Margin="{TemplateBinding Padding}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Content="{TemplateBinding Content}" />
                            <TextBlock Text="{Binding}"
                                        FontFamily="Georgia"
                                        FontSize="15"
                                        Foreground="Red"
                                        HorizontalAlignment="Center"/>
                                     
                        </StackPanel>                               
                    </Border>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

After you finish the style, set the ChartTitle to use it, and then set the bindings:

<telerik:RadChart x:Name="chart">
    <telerik:RadChart.DefaultView>
        <telerik:ChartDefaultView>
            <telerik:ChartDefaultView.ChartTitle>
                <telerik:ChartTitle
                  DataContext="My second chart title"
                  Content="First Title"
                  Style="{StaticResource ChartTitleStyle}"/>                       
            </telerik:ChartDefaultView.ChartTitle>
        </telerik:ChartDefaultView>
    </telerik:RadChart.DefaultView>
</telerik:RadChart>


Kind regards, Petar Kirov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Chart
Asked by
Tony
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Share this question
or