How can I display the X and Y values in the tool tip for radCartesianchart bar series
In radChart, there is a option as below:
<telerik:BarSeriesDefinition ItemToolTipFormat="the X value is #X, the Y value is #Y"ShowItemToolTips="True" />
</telerik:SeriesMapping.SeriesDefinition>
3 Answers, 1 is accepted
You can enable the tooltip in RadCartesianChart by defining a new ChartToolTipBehavior. Then you can customize its appearance via the TooltipTemplate property of the series. I hope this helps.
Regards,
Martin Ivanov
Progress Telerik
Hello
My XAML is as follows:
<telerik:RadCartesianChart Name="chart" HoverMode="FadeOtherSeries" ClipToBounds="False" >
<telerik:RadCartesianChart.ContextMenu>
<ContextMenu>
<MenuItem Header="Export To Image" Click="MenuItem_Click" />
</ContextMenu>
</telerik:RadCartesianChart.ContextMenu>
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:CategoricalAxis />
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis HorizontalAlignment="Right" />
</telerik:RadCartesianChart.VerticalAxis>
<telerik:RadCartesianChart.Behaviors>
<telerik:ChartTooltipBehavior >
</telerik:ChartTooltipBehavior>
</telerik:RadCartesianChart.Behaviors>
</telerik:RadCartesianChart>
In the documentaion there is no example for dynamic bar stacked series. I am not sure how can I have the template when the bar series is not added in the XAML(it is added from code behind).
Without template, the tool tip shown is
Value = xxxx
Category = yyyyy
But I need to change the text as shown below in Bold
Text1=xxxx
Text2=yyyy
There are several ways to get a DataTemplate in code-behind.
- Create it in code using FrameworkElementFactory.
- Save the template as a string and use the XamlReader.Parse() method to create a DataTemplate object.
- Or you can define the template in the resources of the application or the view and use the Resources dictionary in code to get the template. For example:
<
Window.Resources
>
<
DataTemplate
x:Key
=
"chartToolTipTemplate"
>
<!-- some elements here -->
</
DataTemplate
>
</
Window.Resources
>
series.TooltipTemplate =
this
.Resources[
"chartToolTipTemplate"
]
as
DataTemplate;
Regards,
Martin Ivanov
Progress Telerik