Getting the series name when using a tooltip template

The default tooltip includes the series name, value and category; when I use a TooltipTemplate I cannot see how to access the series name - just the value and category. I cannot find an example that seems to show this. Is there a way? I am looking to have a tooltip that shows, series name, a formatted date and a formatted value. Here is is my working code without the series name. I am using a for loop to create multiple line series.

						<RadzenChart Style="height:450px;">
							<RadzenCategoryAxis Padding="20" Formatter=@FormatDate>
								<RadzenAxisTitle Text="Time" />
							</RadzenCategoryAxis>
							<RadzenValueAxis FormatString="{0:F2}">
								<RadzenGridLines Visible="true" />
								<RadzenAxisTitle Text=@GetUnits(sensorTypeData.SensorTypeName) />
							</RadzenValueAxis>
							@for (uint deviceIndex = 0; deviceIndex < m_listSensors?.Count; deviceIndex++)
							{
								<RadzenLineSeries Smooth="true" Data=@sensorTypeData.Data?[ @deviceIndex ] Title=@m_listSensors[(int)@deviceIndex].Location CategoryProperty="Date" ValueProperty="Value" Stroke="@GetLineColour( @sensorTypeData.SensorTypeName, @deviceIndex)" LineType=@GetLineType(deviceIndex)>
									<TooltipTemplate Context="datapoint">
											<div>@datapoint.Date.ToString("dd MMM yy HH:MM")</div>
											<div>@datapoint.Value.ToString(@GetFormat(sensorTypeData.SensorTypeName), CultureInfo.CurrentUICulture)@GetUnits(sensorTypeData.SensorTypeName)</div>									
									</TooltipTemplate>
								</RadzenLineSeries>
							}
							<RadzenLegend Visible="true" />
						</RadzenChart>

Any help /pointers appreciated.

Mark

Hi @naylom,

The TooltipTemplate is defined per series so you already know what that series is.

Hi korchev,
Thanks for the reply; I am probably being dense but since I am producing the lines series in a loop I cannot simply get the series name by (in this case) using something like @m_listSensors[(int)@deviceIndex].Location (as used in the line series Title field) as this will always returns the deviceIndex always seems to return the value when the loop has terminated and is now beyond the bounds of m_listSensors. I am not sure but I think this is something to do with how Blazor renders the page. Hope that makes sense.

You should assign the title to a temp variable first and then use it.

var title = m_listSensors[(int)@deviceIndex].Location;
<RadzenLineSeries Smooth="true"
    Data=@sensorTypeData.Data?[ @deviceIndex ] 
    Title=@title CategoryProperty="Date" ValueProperty="Value" Stroke="@GetLineColour( @sensorTypeData.SensorTypeName, @deviceIndex)" LineType=@GetLineType(deviceIndex)>
								

Here is why this happens: Loop variables used in components not working? - #5 by korchev

This solved the problem; many thanks and also for the link to the underlying reason.