Hi,
I've built a bar chart, and showing item label above bars. But control also displays 0 values when YValue is 0 and no bar is displayed for that item. Is there any way to solve my problem?
I tried to change DataPoint.LabelFormat property for 0-valued data points but it seams that it doesn't work at all :(
The trick I've tried:
|
if(dataPoint.YValue == 0) { dataPoint.Label = string.Empty; |
|
dataPoint.LabelFormat = "#LABEL"; } |
6 Answers, 1 is accepted
Try setting the dataPoint.Label to " " (notice the empty space). This should work.
All the best,
Vladimir Milev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
It works,
Thank you Vladimir Milev!
And another question is how to align the label to the center of the bar?
I've rotated them but they are always shown on the left side of the bar.
Cheers,
Tom
That's a bit trickier. In Silverlight one can do only render transforms and there are problems with the alignment and layout of the content. You may want to consider this forum post.
Greetings,
Vladimir Milev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I am having the same issue.
DataSeries seriesBar = new DataSeries();
seriesBar.Definition =
new BarSeriesDefinition();
DataPoint dp1 = new DataPoint();
dp1.YValue = (
double)c1.CR;
dp1.XCategory =
"X Category Name";
if (dp1.YValue < 0)
{
dp1.YValue = 0;
if (!string.IsNullOrEmpty(countyCode))
{
dp1.Label =
"No" + "\r\n" + "Data";
}
else
{
dp1.Label =
" ";
}
}
seriesBar.Add(dp1);
return seriesBar;
I have two Bar series each having one Data Point If I user empty space for one of them it is displaying empty for both the series. But for the first bar I want to display No data and second one I want to display Blank. It is not working
Please help.
How to hide Item Label style in Pie chart when value is zeroIn XAML <telerikChart:RadChart ItemsSource="{Binding Items}" PaletteBrushesUseSolidColors="True" x:Name="RadChart1" Height="110" Width="110" Background="Transparent" BorderThickness="0" BorderBrush="Transparent"> <telerikChart:RadChart.DefaultSeriesDefinition> <telerikCharting:PieSeriesDefinition ItemStyle="{StaticResource SeriesItemLabelStyle}" LegendDisplayMode="DataPointLabel"> <telerikCharting:PieSeriesDefinition.LabelSettings> <telerikCharting:RadialLabelSettings ShowZeroValueLabels="False"></telerikCharting:RadialLabelSettings> </telerikCharting:PieSeriesDefinition.LabelSettings> </telerikCharting:PieSeriesDefinition> </telerikChart:RadChart.DefaultSeriesDefinition> <telerikChart:RadChart.PaletteBrushes> <SolidColorBrush Color="#3597CA"></SolidColorBrush> <SolidColorBrush Color="#11784B"></SolidColorBrush> </telerikChart:RadChart.PaletteBrushes> <telerikChart:RadChart.DefaultView> <telerikCharting:ChartDefaultView> <telerikCharting:ChartDefaultView.ChartLegend> <telerikCharting:ChartLegend x:Name="chartLegend" Header="" UseAutoGeneratedItems="True" Visibility="Collapsed" /> </telerikCharting:ChartDefaultView.ChartLegend> <telerikCharting:ChartDefaultView.ChartArea> <telerikCharting:ChartArea IsNoDataMessageEnabled="false" SmartLabelsEnabled="True" LabelFormatBehavior="None" LegendName="chartLegend" EnableAnimations="True" EnableStripLinesAnimation="False" Background="Transparent"> </telerikCharting:ChartArea> </telerikCharting:ChartDefaultView.ChartArea> </telerikCharting:ChartDefaultView> </telerikChart:RadChart.DefaultView> <telerikChart:RadChart.SeriesMappings> <telerikCharting:SeriesMapping> <telerikCharting:SeriesMapping.ItemMappings> <telerikCharting:ItemMapping FieldName="Name" DataPointMember="LegendLabel" /> <telerikCharting:ItemMapping FieldName="Count" DataPointMember="YValue" /> </telerikCharting:SeriesMapping.ItemMappings> <telerikCharting:SeriesMapping.SeriesDefinition> <telerikCharting:PieSeriesDefinition SeriesItemLabelStyle="{StaticResource SeriesItemLabelStyle}" ItemLabelFormat="#VAL %" LabelOffset="0.6" ItemStyle="{StaticResource CustomPie}" /> </telerikCharting:SeriesMapping.SeriesDefinition> </telerikCharting:SeriesMapping> </telerikChart:RadChart.SeriesMappings> </telerikChart:RadChart>In Code Behind public partial class SolidPieChart : UserControl { public SolidPieChart() { InitializeComponent(); this.LayoutRoot.DataContext = this; } public ObservableCollection<TradeData> Items { get { return TradeData.GetWeeklyData(); } } } public class TradeData { public string Name { get; set; } public double Count { get; set; } public static ObservableCollection<TradeData> GetWeeklyData() { ObservableCollection<TradeData> tradeData = new ObservableCollection<TradeData>(); tradeData.Add(new TradeData { Name = "name1", Count = 0 }); tradeData.Add(new TradeData { Name = "name2", Count = 0 }); //tradeData.Add(new TradeData { Name = "name3", Count = 0}); return tradeData; }Please, use the "ShowZeroValueLabels" property on the label settings class.
Regards,
Vladimir Milev
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!