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

Format Lablel to display Negative currency Values and Bold

3 Answers 179 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Mallikharjun Mulagundla
Top achievements
Rank 1
Mallikharjun Mulagundla asked on 19 May 2010, 07:55 AM

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

3 Answers, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 21 May 2010, 11:38 AM
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.
0
Mallikharjun Mulagundla
Top achievements
Rank 1
answered on 21 May 2010, 02:53 PM
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
0
Velin
Telerik team
answered on 26 May 2010, 03:10 PM
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.
Tags
Chart (Obsolete)
Asked by
Mallikharjun Mulagundla
Top achievements
Rank 1
Answers by
Velin
Telerik team
Mallikharjun Mulagundla
Top achievements
Rank 1
Share this question
or