Format Lablel to display Negative currency Values and Bold

Thread is closed for posting
4 posts, 0 answers
  1. Mallikharjun Mulagundla
    Mallikharjun Mulagundla avatar
    28 posts
    Member since:
    Nov 2009

    Posted 19 May 2010 Link to this post

    Hi,

    How can I format the value in the chart to display Negative vlaues when my data is in -ve values.
    I have currently set it to  the following:
     

    s.DefaultLabelValue = "#Y{C0}"

    Aslo, I want to set Chart Slices Label Font to Bold.

    Thanks, Malli

  2. Velin
    Admin
    Velin avatar
    391 posts

    Posted 21 May 2010 Link to this post

    Hello Mallikharjun Mulagundla,

    Please, explain in more details what you need to do. Thanks.

    Regards,
    Velin
    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. Mallikharjun Mulagundla
    Mallikharjun Mulagundla avatar
    28 posts
    Member since:
    Nov 2009

    Posted 21 May 2010 Link to this post

    I am binding same dataset to Chart, which has 2 Chart Serires. 1st Chart sesries  I set DefaultLabelValue as "#Y{C0}" and for the 2nd Chart series, I set as "#%".

    I am able to -ve values in the Chart for "%" (2nd Chart Series). For 1st Chart Series it is showing as +ve for Currency, even though its actual value is -ve. Check the following code
    <telerik:RadChart ID="PartnersChart" BorderColor="Black" BorderWidth="1px" runat="server" Width="770px" Height="290px" DefaultType="Pie" SkinsOverrideStyles="true" AutoLayout="true" AutoTextWrap="true" CreateImageMap="false" OnItemDataBound="PartnersChart_ItemDataBound">  
       <Series> 
           <telerik:ChartSeries DataYColumn="Value" Type="Pie" DefaultLabelValue="#Y{C0}">  
               <Appearance LegendDisplayMode="ItemLabels"/>   
           </telerik:ChartSeries> 
           <telerik:ChartSeries DataYColumn="Value" Type="Pie" DefaultLabelValue="#%">  
              <Appearance LegendDisplayMode="Nothing" /> 
           </telerik:ChartSeries> 
       </Series> 
    </telerik:RadChart> 

    Also,. check the attached snapshot.

    Thanks, Malli
  4. Velin
    Admin
    Velin avatar
    391 posts

    Posted 26 May 2010 Link to this post

    Hello Mallikharjun Mulagundla,

    One possible way you could go is to remove the DefaultlabelValue format and manually format the label values on the ItemDataBound event. Here is the code:
        chart.ItemDataBound += new EventHandler<ChartItemDataBoundEventArgs>(uxFieldChart_ItemDataBound);
     
    void uxFieldChart_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
    {
        string negative = string.Empty;
     
        double value = Convert.ToDouble((e.DataItem as DataRowView).Row.ItemArray[0]);
     
        if (value < 0)
            negative = "-";
     
        e.SeriesItem.Label.TextBlock.Text = negative + string.Format("{0:C}", value);
     
        e.SeriesItem.Label.TextBlock.Appearance.TextProperties.Font = new Font("Verdana", 9, FontStyle.Bold);
    }


    Kind regards,
    Velin
    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.
Back to Top