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

Chart legend item Names not showing

1 Answer 83 Views
This is a migrated thread and some comments may be shown as answers.
steve white
Top achievements
Rank 1
steve white asked on 06 May 2010, 10:16 PM
I have what I believe should be a simple problem, my legend items are just showing up as item0 - item6. I need them to show up with the name of the object in my items from the database.

I'm using a dataset to link to SQL, my 2 fields in my dataset are "sales" and "productclass".
I'm not sure what I missed, I followed the examples from the legend section exactly I think.

thanks for any help you can provide.

<UserControl x:Class="UserControl2" 
    xmlns:x="" Width="300" Height="300" xmlns:telerik=""
        <telerik:RadChart Name="RadChart1"  > 

Imports Telerik.Windows.Controls.Charting 
Imports System.Data 
Partial Public Class UserControl2 
    Private Shared tacust As New DataSet1TableAdapters.pcSumTableAdapter 
    Private Shared dscust As New DataSet1 
    Private Shared m_sales As DataTable 
    Public Shared ReadOnly Property Sales() As DataTable 
            Return m_sales 
        End Get 
    End Property 
    Private Sub UserControl1_Initialized(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Initialized 
        RadChart1.DefaultSeriesDefinition = New PieSeriesDefinition() 
        RadChart1.DefaultView.ChartLegend.UseAutoGeneratedItems = True 
        RadChart1.DefaultView.ChartLegend.Header = "Top 10" 
        m_sales = dscust.Tables("pcSum"
        RadChart1.ItemsSource = m_sales 
    End Sub 
End Class 

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 11 May 2010, 01:26 PM
Hi steve white,

In order for the Chart legend to display the items from your database, instead of auto-generating them, you need to create a data bound chart and define two ItemMappings - one that binds the "sales" from your dataset to DataPointMember.YValue and the other for binding the "productclass" to DataPointMember.LegendLabel.

Please, refer to this help topic, from which Binding the RadChart section should provide you with more information on how to bind your chart to your database.

Hope this helps.If you need further assistance, please, do not hesitate to contact us. 

the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Asked by
steve white
Top achievements
Rank 1
Answers by
Telerik team
Share this question