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

Chart legend item Names not showing

1 Answer 102 Views
Chart
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.
steve

<UserControl x:Class="UserControl2" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="300" Height="300" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    <Grid> 
        <telerik:RadChart Name="RadChart1"  > 
             
        </telerik:RadChart> 
    </Grid> 
</UserControl> 
 

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 
        Get 
            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" 
        tacust.Fill(dscust.pcSum) 
        m_sales = dscust.Tables("pcSum"
        RadChart1.ItemsSource = m_sales 
    End Sub 
End Class 

1 Answer, 1 is accepted

Sort by
0
Nikolay
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. 

Greetings,
Nikolay
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.
Tags
Chart
Asked by
steve white
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or