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

Series Item Label Font in Chart

1 Answer 133 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 2
Joel asked on 08 Mar 2012, 10:19 PM
I can't find this anywhere.  Your help is appreciated.

I want to change the font and color of the series item label in my chart.  The properties all seem to be exposed as I have changed every font in the chart so far except this label.

I have tried it several different ways in the code behind as well with no luck.

I can go in and set it via properties, series collection, items but that does not display in the report (just the VS preview).  I am databinding in the code behind in new:    Chart1.DataSource = _ds.Tables(0) 

Suggestions greatly appreciated.

Private Sub Chart1_ItemDataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles Chart1.ItemDataBound
    Chart1.Series(1).Appearance.TextAppearance.TextProperties.Color = Color.Red
 
    Dim myseries As ChartSeries
    Dim myitem As ChartSeriesItem
 
    For Each myseries In Chart1.Series
        myseries.Appearance.TextAppearance.TextProperties.Color = Color.Red
 
        For Each myitem In myseries.Items
            myitem.Label.TextBlock.Appearance.TextProperties.Color = Color.Red
            myitem.Label.TextBlock.Text = "xxxx"
        Next
    Next
 
 
End Sub

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 09 Mar 2012, 08:48 AM
Hi Joel,

This is a known limitation of the chart item, whenever you bind it via the DataSource property, you cannot alter some of its styles/formattings. Additionally the ItemDataBound event of the chart item is too late to do this and this event is not the same as in the RadChart for ASP.NET AJAX control, such changes can be done latest in the NeedDataSource event. The solution is to create and bind the chart manually which gives you full control over it. For a sample code snippet please refer to the Data Binding Chart to a Generic List of Objects.

Regards,
Steve
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
Tags
General Discussions
Asked by
Joel
Top achievements
Rank 2
Answers by
Steve
Telerik team
Share this question
or