Item Labels in a Stacked Bar Chart

Thread is closed for posting
6 posts, 1 answers
  1. Paul Smith
    Paul Smith avatar
    2 posts
    Member since:
    Mar 2010

    Posted 31 Mar 2010 Link to this post

    Is it possible (and if so how) to only show the total of the bar as the label above it, on a stacked bar chart.
    If I turn on item labels, it puts a label for each stack segment, where as I want just the total of all segments to display above the bar.

  2. Answer
    Ves
    Admin
    Ves avatar
    2926 posts

    Posted 02 Apr 2010 Link to this post

    Hi Paul,

    You can hide the labels for all the series, except for the last one. For it, you can use the #STSUM token to display the stacked sum. Here is an example:

    <telerik:RadChart runat="server" ID="RadChart1" AutoLayout="True" >
               <Series>
                   <telerik:ChartSeries Name="Series 1" Type="StackedBar">
                       <Appearance>
                           <LabelAppearance Visible="False">
                           </LabelAppearance>
                       </Appearance>
                       <Items>
                           <telerik:ChartSeriesItem Name="Item 1" YValue="3">
                           </telerik:ChartSeriesItem>
                           <telerik:ChartSeriesItem Name="Item 2" YValue="2">
                           </telerik:ChartSeriesItem>
                       </Items>
                   </telerik:ChartSeries>
                   <telerik:ChartSeries Name="Series 2" Type="StackedBar">
                       <Appearance>
                           <LabelAppearance Visible="False">
                           </LabelAppearance>
                       </Appearance>
                       <Items>
                           <telerik:ChartSeriesItem Name="Item 1" YValue="3">
                           </telerik:ChartSeriesItem>
                           <telerik:ChartSeriesItem Name="Item 2" YValue="1">
                           </telerik:ChartSeriesItem>
                       </Items>
                   </telerik:ChartSeries>
                   <telerik:ChartSeries DefaultLabelValue="#STSUM" Name="Series 3"
                       Type="StackedBar">
                       <Items>
                           <telerik:ChartSeriesItem Name="Item 1" YValue="4">
                           </telerik:ChartSeriesItem>
                           <telerik:ChartSeriesItem Name="Item 2" YValue="5">
                           </telerik:ChartSeriesItem>
                       </Items>
                   </telerik:ChartSeries>
               </Series>
           </telerik:RadChart>

    You can find more details about the available tokens in this help topic.

    Kind regards,
    Ves
    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.
  3. Paul Smith
    Paul Smith avatar
    2 posts
    Member since:
    Mar 2010

    Posted 05 Apr 2010 Link to this post

    Thank you! Much appreciated.
  4. Travis
    Travis avatar
    226 posts
    Member since:
    Jan 2003

    Posted 02 May 2011 Link to this post

    What would be the syntax for this if you were binding to a database?
  5. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 05 May 2011 Link to this post

    Hi Travis,

    The syntax would be the same. However, when databinding, it is possible that you have no ChartSeries before the databinding occurs. In this case, you can wire the DataBound event of RadChart and update the ChartSeries there.

    Best regards,
    Ves
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Travis
    Travis avatar
    226 posts
    Member since:
    Jan 2003

    Posted 05 May 2011 Link to this post

    Thank you.  That would expalin my problem.  I ended up using the tooltip control and setting #STSUM on the ItemDataBound event of the chart.
Back to Top