I want to visualize/highlight selected datapoints in my charts. One of the things I want is to increase the fontsize on the selected items label (via binding), but the labels do not automatically resize (resulting in clipped text). Is it possible to resize/refresh labels in a chart without rendering the series again?
4 Answers, 1 is accepted
0
Hello Jorn,
I guess you are using LabelTemplate. Can you confirm this?
The reason behind this behavior is that the RadChartView doesn't listen for changes in its templates (including the LabelTemplate). Basically if you want the chart to be notified and refreshed you will need to make a change in property of its API.
When the chart start to draw itself it will go through the LabelTemplate of the axis and it will calculate how much space will be necessary for the labels. This will happen only once when the chart is loaded, which means that if you alter the text inside the labels they will use the space that was allocated earlier and they will be clipped.
In order to achieve your requirement you can try to set Height (for example 80) of the TextBlock that holds the label.
Please let me know if this helps.
Regards,
Martin
Telerik
I guess you are using LabelTemplate. Can you confirm this?
The reason behind this behavior is that the RadChartView doesn't listen for changes in its templates (including the LabelTemplate). Basically if you want the chart to be notified and refreshed you will need to make a change in property of its API.
When the chart start to draw itself it will go through the LabelTemplate of the axis and it will calculate how much space will be necessary for the labels. This will happen only once when the chart is loaded, which means that if you alter the text inside the labels they will use the space that was allocated earlier and they will be clipped.
In order to achieve your requirement you can try to set Height (for example 80) of the TextBlock that holds the label.
Please let me know if this helps.
Regards,
Martin
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0

Trude
Top achievements
Rank 2
answered on 26 Aug 2014, 09:05 AM
Yes, I use LabelTemplate. I understand the restrictions (in the API/control) you describle but I don't see how changing the TextBlock height will help? It just appears stretched vertically and the text is still clipped horizontally. Here's my LabelTemplate:
<
DataTemplate
x:Key
=
"LabelTemplateString"
>
<
Border
Background
=
"{Binding Path=Presenter, Converter={StaticResource PaletteExtractorConverter}}"
BorderBrush
=
"#FFCCCCCC"
BorderThickness
=
"1"
>
<
TextBlock
Text
=
"{Binding DataItem.label}"
Margin
=
"3,0,3,1"
FontFamily
=
"Segoe UI"
FontSize
=
"{Binding DataItem.label_size}"
FontWeight
=
"{Binding DataItem.label_weight}"
Foreground
=
"White"
/>
</
Border
>
</
DataTemplate
>
0
Accepted
Hi Jorn,
Please excuse me, I though you are talking about the axis' labels. However, the same rule about the label template applies for the series' templates too. To update the labels you can replace the label definition with a new one when you change the font size. Here is an example in code:
I hope this helps.
Regards,
Martin
Telerik
Please excuse me, I though you are talking about the axis' labels. However, the same rule about the label template applies for the series' templates too. To update the labels you can replace the label definition with a new one when you change the font size. Here is an example in code:
private
void
ChartSelectionBehavior_SelectionChanged(
object
sender, Telerik.Windows.Controls.ChartView.ChartSelectionChangedEventArgs e)
{
if
(e.AddedPoints.Count > 0)
{
var selectedPoint = e.AddedPoints.First()
as
CategoricalDataPoint;
if
(selectedPoint !=
null
)
{
var dataItem = selectedPoint.DataItem
as
DataItem;
dataItem.LabelSize = 16;
var definition =
new
ChartSeriesLabelDefinition();
definition.Template =
this
.Resources[
"LabelTemplateString"
]
as
DataTemplate;
var presenter = selectedPoint.Presenter
as
BarSeries;
presenter.LabelDefinitions.Clear();
presenter.LabelDefinitions.Add(definition);
}
}
else
{}
// return the old font size
}
I hope this helps.
Regards,
Martin
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0

Trude
Top achievements
Rank 2
answered on 28 Aug 2014, 11:18 PM
Thanks for pointing me in the right direction (datapoint -> presenter -> labeldefinition). It works now!