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

RadHTMLChart and database legend

1 Answer 222 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 12 Jul 2013, 09:12 PM
<telerik:RadHtmlChart runat="server" Width="400px" Height="300px" ID="RadHTMLChart1" DataSourceID="SqlDataSource2" >
             <Legend>
                 <Appearance Position="Top">
                 </Appearance>
             </Legend>
             <PlotArea>
                  <Series >
                        
                       <telerik:PieSeries DataFieldY="SumPeopleServed" Name="People Served" StartAngle="90"  >
                       
                       </telerik:PieSeries>
                  </Series>
                   
             </PlotArea>
             <ChartTitle Text="% Samples by RDS">
              <Appearance>
              <TextStyle FontSize="16px"></TextStyle>
              </Appearance>
             </ChartTitle>
        </telerik:RadHtmlChart>
          
    
       
 
   <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:cnPanDMSWEB_dead %>" SelectCommand="Select RDSNUm, Sum(PeopleServed) as 'SumPeopleServed' from mcop_OrderEntry Where TransDate >= @StartDate and TransDate <= @EndDate Group By RDSNum">
       <SelectParameters>
           <asp:ControlParameter ControlID="dtStartDate" DefaultValue="7/1/2013" Name="StartDate" PropertyName="SelectedDate" />
           <asp:ControlParameter ControlID="dtEndDate" DefaultValue="7/31/2013" Name="EndDate" PropertyName="SelectedDate" />
       </SelectParameters>
   </asp:SqlDataSource>



I'm trying to get a RadHTMLChart in PieChart mode to generate the legend from a column in a SQL-Generated dataset

Here is the example of the dataset:

RDSNum SumPeopleServed
----------------------------------------------------
1 834989
8888 36956
9999 641836


Attached is a snapshot of the control that correctly shows the "SumPeopleServed" values in the pie chart.

But, I can't seem to get the "RDSNum" to show in the legend so that the user can see what each color represents.

I don't see anything in the 'Config Wizard" that allows me to set the column used for the legend, much like the "Y-axis" column to be used for the pie chart values....

And I examples I see for SQL-Databound stuff for piecharts seem to have the legend values assigned at design-time, which doesn't help me.  

Can anyone point me in the right direction?  I'm sure I'm missing something really really dumb... I can't image a control like this would have the ability to use values dynamically generated from a dataset, but then have to have the legend pre-defined at design-time...


Jay



1 Answer, 1 is accepted

Sort by
0
Stamo Gochev
Telerik team
answered on 17 Jul 2013, 07:49 AM
Hi Jay,

By design, the text that will appear in the RadHtmlChart's legend for each item is determined by the serie name ("People Served" in your case). If you want to change this, you can take advantage of the NameField property of the PieSeries:

<telerik:PieSeries DataFieldY="SumPeopleServed" NameField="CustomLegendText" >

where ""CustomLegendText" could be an additional column in your SqlDataSource, which contains the concatenation of some custom text and the corresponding RDSNum value. Could you try this idea and tell me if you were able to apply it?

Regards,
Stamo Gochev
Telerik
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 the blog feed now.
Tags
Chart (HTML5)
Asked by
Jay
Top achievements
Rank 1
Answers by
Stamo Gochev
Telerik team
Share this question
or