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

ChartTitle and SubTitle

7 Answers 205 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Paulo
Top achievements
Rank 1
Paulo asked on 27 Apr 2012, 12:19 PM
How can I do a subtitle with different font and size? Is possible?

7 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 01 May 2012, 09:16 AM
Hi Paulo,

You may use new line to separate the text , i.e. have a subtitle. For example:

<TextBlock Text="This is first line.
This is on another line">

 
instead of this:

<TextBlock Text="This will appear as a single line.">

You can achieve this in code behind too:

this.radChart1.ChartTitle.TextBlock.Text += "first line here" + System.Environment.NewLine + "second line here";

To be able to have different styles applied to each line you can try something like this.

this.radChart1.ChartTitle.TextBlock.Text = "Main Title";
var titleStyleClone = (Telerik.Charting.Styles.StyleTextBlock)(this.radChart1.ChartTitle.TextBlock.Appearance.Clone());
TextBlock textBlockChartTitleSub = new TextBlock(titleStyleClone);
textBlockChartTitleSub.Parent = this.radChart1.ChartTitle;
textBlockChartTitleSub.Text = "another chart title";
textBlockChartTitleSub.Appearance.TextProperties.Color = System.Drawing.Color.Blue;
textBlockChartTitleSub.Appearance.TextProperties.Font = new System.Drawing.Font("Verdana", 10);
textBlockChartTitleSub.Appearance.Position.Y += 30;
this.radChart1.ChartTitle.Add(textBlockChartTitleSub);

Greetings,
Evgenia
the Telerik team

If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Steven
Top achievements
Rank 1
answered on 08 May 2012, 06:34 AM
Hi Evgenia,

I tried your code above to have different styles applied for the 2nd line of the chart title but got an issue. The chart title is not big enough to hold both lines & thus, only the top half of 2nd line show up. Plz see my attached picture.

I tried many ways but cannot change the height of the chart title.

Can you advise me a solution for this? Many thanks.
0
Evgenia
Telerik team
answered on 08 May 2012, 09:10 AM
Hello Paulo,

You can control the size of the Title by turning off the AutoSize property and providing your own Height and Width properties. You will also need to provide bigger top Margin for the PlotArea so that the chart title won't be overlapped by the plot area:

this.RadChart1.ChartTitle.Appearance.Dimensions.AutoSize = false;
this.RadChart1.ChartTitle.Appearance.Dimensions.Height = 50;
this.RadChart1.ChartTitle.Appearance.Dimensions.Width = 170;
this.RadChart1.PlotArea.Appearance.Dimensions.Margins.Top = 70;

Regards,
Evgenia
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
kencox
Top achievements
Rank 1
answered on 11 Dec 2012, 03:10 PM
Is the sample code for different styles applied to each Chart Title line actually working code?

I'd really like this functionality. Is there a sample project somewhere?

Ken
0
Evgenia
Telerik team
answered on 13 Dec 2012, 01:31 PM
Hello Ken,

 Modifying the Appearance properties of the second TextBlock won't affect the original one, i.e. you can have different styles for them as shown in the code snippet of the previous post.

Regards,
Evgenia
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
kencox
Top achievements
Rank 1
answered on 13 Dec 2012, 03:38 PM
Hi Evgenia

Thanks for the reply.

I couldn't get that code to work. Could you put it into a sample project for download?

Thanks,

Ken
0
Evgenia
Telerik team
answered on 18 Dec 2012, 09:59 AM
Hello Ken,

 You may find a sample attached where this is demonstrated.

Kind regards,
Evgenia
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Chart (Obsolete)
Asked by
Paulo
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Steven
Top achievements
Rank 1
kencox
Top achievements
Rank 1
Share this question
or