6 Answers, 1 is accepted
You can set label format for Bar Series like this:
seriesMapping.SeriesDefinition.ItemLabelFormat = "#Y{0.0}%";You refer below link for more information on label formats.
http://www.telerik.com/help/silverlight/radchart-features-format-expressions.html
Thanks & Regards
Rahul
this is for the ChartView and not RadChart
the help you have posted doesn't correlate to anything I can find in regards to ChartView
You can achieve this with RadChartView like this:
<telerik:BarSeries.LabelDefinitions> <telerik:ChartSeriesLabelDefinition HorizontalAlignment="Center" Format="{} {0:F1}"/> </telerik:BarSeries.LabelDefinitions>All the best,
Evgenia
the Telerik team
I have the same requirement, but with addition that user can configure in application properties the number of decimals that chart will display. Since Format is not dependency property, we cannot bind it to a property. How can I achieve this, assuming that, for example, I have this property in ViewModel:
public string NumberFormat{ get { return "{} {0:F" + ApplicationConfiguration.NumberOfDecimals + "}"; }}Regards,
Goran
You can achieve this the same way it was done for AxisXLabelFormat and AxisYLabelFormat in this online example with source code. The properties are registered in the ViewModel as follows:
private string _axisXLabelFormat; private string _axisYLabelFormat; public string AxisXLabelFormat { get { return this._axisXLabelFormat; } set { if (this._axisXLabelFormat != value) { this._axisXLabelFormat = value; this.OnPropertyChanged("AxisXLabelFormat"); } } } public string AxisYLabelFormat { get { return this._axisYLabelFormat; } set { if (this._axisYLabelFormat != value) { this._axisYLabelFormat = value; this.OnPropertyChanged("AxisYLabelFormat"); } } } They are set in the DisplayLine() method in ExampleViewModel.cs and bound to their corresponding chart properties in xaml.
I hope this information helps.
Regards,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Goran's example did not work for me, but i figured it out. I just needed to remove the first set of brackets {} from the string and the then it was fine.
ChartSeriesLabelDefinition labelDefinition = new ChartSeriesLabelDefinition();
labelDefinition.Binding = new PropertyNameDataPointBinding() { PropertyName = "Y" };
labelDefinition.Format = "{0:N1}"; // {0:N1} == "0.0"
BarSeries barSeries = new BarSeries();
barSeries.ShowLabels = true;
barSeries.LabelDefinitions.Add(labelDefinition);
Here are some useful links for numeric formatting.
string.Formats for regular numbers
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
string.Formats for custom numbers
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
string.Formats Thousands=K Millions=M Billions=B etc.
http://stackoverflow.com/questions/11731996/string-format-numbers-thousands-123k-millions-123m-billions-123b
Regards,
Heath Morris