This question is locked. New answers and comments are not allowed.
Abdulhameed
Top achievements
Rank 1
Abdulhameed
asked on 02 Jan 2012, 01:41 PM
I am creating a pie Chart where I have almost 8 section, showing all label doesn't look very nice so I decided to show the label for the selected item only.
How can I display item label for the selected item only?
Thanks
How can I display item label for the selected item only?
Thanks
4 Answers, 1 is accepted
0
Hi Abdulhameed,
I am not sure I understand you fully. You mentioned that showing all labels does not look very nice. Are you showing the value in the labels? Or are you showing some text (like a category name).
If you are showing category name - I would suggest not to show this category name in the item label, but show it in the legend and in the item label show the value.
If you are showing values in the item labels - I do not see an obvious reason not to like the results. If you can clear that, than we might be able to help. You can send us a screenshot of the output and a drawing of the desired results.
Now, for the second part of your question - yes there is way to show the label of a particular slice. It can not be achieved with out-of-the-box means but you can implement it manually. You just need to find the hovered item in code behind and set its labels visibility to Visible (and collapse all others).
The code below should help you understand what I have in mind.
You can examine our demos here where you can also get some new ideas.
All the best,
Petar Marchev
the Telerik team
I am not sure I understand you fully. You mentioned that showing all labels does not look very nice. Are you showing the value in the labels? Or are you showing some text (like a category name).
If you are showing category name - I would suggest not to show this category name in the item label, but show it in the legend and in the item label show the value.
If you are showing values in the item labels - I do not see an obvious reason not to like the results. If you can clear that, than we might be able to help. You can send us a screenshot of the output and a drawing of the desired results.
Now, for the second part of your question - yes there is way to show the label of a particular slice. It can not be achieved with out-of-the-box means but you can implement it manually. You just need to find the hovered item in code behind and set its labels visibility to Visible (and collapse all others).
The code below should help you understand what I have in mind.
public
MainPage()
{
InitializeComponent();
this
.radChart.SeriesMappings[0].SeriesDefinition.InteractivitySettings.HoverScope = Telerik.Windows.Controls.Charting.InteractivityScope.Item;
this
.radChart.DefaultView.ChartArea.HoverChanged +=
new
EventHandler<Telerik.Windows.Controls.Charting.ChartHoverChangedEventArgs>(ChartArea_HoverChanged);
}
void
ChartArea_HoverChanged(
object
sender, Telerik.Windows.Controls.Charting.ChartHoverChangedEventArgs e)
{
ChartArea chartArea = sender
as
ChartArea;
if
(chartArea ==
null
)
{
return
;
}
var hoveredDataItems = e.HoveredItems.Select(dp => dp.DataItem);
foreach
(var item
in
chartArea.ChildrenOfType<SeriesItemLabel>())
{
if
(hoveredDataItems.Contains(item.DataPoint.DataItem))
{
item.Visibility = System.Windows.Visibility.Visible;
}
else
{
item.Visibility = System.Windows.Visibility.Collapsed;
}
}
}
You can examine our demos here where you can also get some new ideas.
All the best,
Petar Marchev
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Abdulhameed
Top achievements
Rank 1
answered on 07 Jan 2012, 08:25 AM
I have attached a screen shot of my Pie Chart as you can see the chart is very corded and even when I tried the spider mood it didn't display all labels properly may be because of space availability.
My goal is to hide all labels except selected slice.
My goal is to hide all labels except selected slice.
0
Hi,
Indeed the chart looks crowded. Is it possible to make it bigger?
In my previous response I provided you with some code to help you only show the hovered item's label. Did you try this approach for your project?
Here is one more thing you can try. Set the ChartArea's property SmartLabelsEnabled to true.
If this doesn't help you can also consider using a horizontal bar series instead.
Kind regards,
Petar Marchev
the Telerik team
Indeed the chart looks crowded. Is it possible to make it bigger?
In my previous response I provided you with some code to help you only show the hovered item's label. Did you try this approach for your project?
Here is one more thing you can try. Set the ChartArea's property SmartLabelsEnabled to true.
If this doesn't help you can also consider using a horizontal bar series instead.
Kind regards,
Petar Marchev
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Abdulhameed
Top achievements
Rank 1
answered on 28 Jan 2012, 11:01 AM
Actually I changed it to bar chart. however I don't see a need to only show labels to hovered items because to achieve this I could simply enable tooltip