This is a migrated thread and some comments may be shown as answers.
Trouble binding Label field to Column
1 Answer 32 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Nick asked on 08 Oct 2008, 05:15 PM
I need to display what should be a pretty basic Pie Chart, but am having trouble with the Labels.

The data is all coming from a SQL database, and it's only two columns.  The "Chart Label" is a pre-calculated Label that I'd like to use on each slice of the pie chart.  Occurences are, the values that the chart will be.... charting....

Occurrences     |    Chart Label
2                      |   Item Label 1 (2)
5                      |   Item Label 2 (5)
6                      |   Item Label 3 (6)
2                      |   Item Label 4 (2)
3                      |   Item Label 5 (3)

So in my ASPX code, I have the following:
<telerik:RadChart ID="RadChart1" runat="server" DataSourceID="SqlDataSource1" DefaultType="Pie" Skin="WebBlue" IntelligentLabelsEnabled="True" AutoTextWrap="True" AutoLayout="True" SeriesOrientation="Horizontal"
            <telerik:ChartSeries DataLabelsColumn="ChartLabel" DataYColumn="Occurrences" Name="Occurrences" Type="Pie"
                    <LabelAppearance Distance="15"
                    <Border Color="73, 86, 101" /> 
                    <TextAppearance TextProperties-Color="140, 140, 140"
                    <FillStyle FillType="ComplexGradient" MainColor="94, 117, 142"
                                <telerik:GradientElement Color="94, 117, 142" /> 
                                <telerik:GradientElement Color="116, 138, 162" Position="0.5" /> 
                                <telerik:GradientElement Color="139, 160, 183" Position="1" /> 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT COUNT(*) AS [Occurrences], incidentCode + ' (' + CAST(COUNT(*) AS nvarchar) + ')' AS [ChartLabel] FROM Incidents GROUP BY incidentCode"

Note that I'm trying to bind the label text to the "Chart Label" field.  Am I going about this in the wrong way, because it is not working... instead, the label is displaying the value in the "Occurrences" field. 

Even if I go into the Chart Wizard to set the Label field to "Chart Label" - nothing happens and the value is not saved.



1 Answer, 1 is accepted

Sort by
Telerik team
answered on 09 Oct 2008, 07:04 AM
Hi Nick,

Your code seems to be correct, but you have hit an old bug in RadChart. It has already been fixed. Please, download the latest release and give it a try.

the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question