The SDK Tooltip example (Telerik xaml-sdk-master\ChartView\WPF\Tooltip) works fine. But if I change the series from bar to line,
the tooltip will not show again.
Only change one line:
<telerik:BarSeries CategoryBinding="Quarter" ValueBinding="Profit" />
to:
<telerik:LineSeries CategoryBinding="Quarter" ValueBinding="Profit" />
So, how can I show simple tooltip on LineSeries or ScatterLineSeries?
Thanks.
7 Answers, 1 is accepted
The tooltip behavior of the RadChartView suite depends on the series default visual element which describes its data points. Since the LineSeries doesn't have a default visual presenter for its points a tooltip is not displayed. The first note (the blue paragraph) in the Tooltip help article describes this.
In order to show a tooltip for the line series you can define a PointTemplate for the LineSeries. For example:
<
telerik:LineSeries.PointTemplate
>
<
DataTemplate
>
<
Ellipse
Width
=
"20"
Height
=
"20"
Fill
=
"Red"
/>
</
DataTemplate
>
</
telerik:LineSeries.PointTemplate
>
I hope this information helps.
Regards,
Martin
Telerik
See What's Next in App Development. Register for TelerikNEXT.
The tooltip showed after define PointTemplate.
Regards,
Yang
Martin -
I'm able to use the XAML you show for plots with a couple of series. How can I do the same thing in the C# for a plot with multiple series added by the user?
You can define the DataTemplate in the main view or the application resources and get it from the Resource dictionary when the series is created. For example:
<
Window.Resources
>
<
DataTemplate
x:Key
=
"seriesPointTemplate"
>
<
Ellipse
Width
=
"20"
Height
=
"20"
Fill
=
"Red"
/>
</
DataTemplate
>
</
Window.Resources
>
series.PointTemplate = (DataTemplate)
this
.Resources[
"seriesPointTemplate"
];
// where 'this' is the Window object (for example the MainWindow)
Or you can create the DataTemplate in code, but this is a bit harder and hard to maintain. You can see how to do that in the following StackOverflow question.
Regards,
Martin
Telerik by Progress
LineSeries lineSeries = new LineSeries();
lineSeries.CategoryBinding = new PropertyNameDataPointBinding(XasisFeild);
lineSeries.ValueBinding = new PropertyNameDataPointBinding(YaxisFeild);
lineSeries.LegendSettings = new SeriesLegendSettings { Title = YaxisFeild };
//lineSeries.ToolTip = YaxisFeild;
lineSeries.ItemsSource = listOfDataToPlot;
lineSeries.Stroke = SetLineSeriesColor(seriesCount);
Rectangle rectangle = new Rectangle() { Height = 10, Width = 10 };
Type type = rectangle.GetType();
DataTemplate dataTemp = new DataTemplate(type);
// dataTemp.DataType = type;
lineSeries.PointTemplate = dataTemp;
return lineSeries;
This is how I'm getting line series and adding it to chart as a child. Still I'm not seeing my tooltip and I'm not able to select points on series. I wanted to select one or range of point based on selection. Doing this in code behind not in XAML. Plz help me with this.
The tooltip will display only if you have a visuals for the data points. You can show this by setting PointTemplate or DefaultVisualStyle property of the series. You can see how to create a DataTemplate in code in the following blog post. Also, check the following stackoverflow topic for creating a Style in code.
Regards,
Martin Ivanov
Progress Telerik