TrackballTemplate

I use trackballTemplate in LineSeries, my code is as follows.

In the TBlockRealtimeChartModel, there are four collections: real-time position, real-time temperature, real-time alarm information, and real-time displacement value. Can I modify the trackballTemplate to display all of them?

        <Border
            Grid.Row="1"
            Margin="5"
            BorderBrush="#04bee0"
            BorderThickness="2"
            CornerRadius="2">
            <syncfusion:SfChart
                Margin="20,5,20,5"
                DataContext="{Binding TBlockRealtimeChartModel}">
                <syncfusion:SfChart.Resources>
                    <Style x:Key="lineStyle" TargetType="Line">
                        <Setter Property="Stroke" Value="#04bee0" />
                        <Setter Property="StrokeThickness" Value="1" />
                    </Style>
                </syncfusion:SfChart.Resources>

                <syncfusion:SfChart.Behaviors>
                    <syncfusion:ChartCrossHairBehavior HorizontalLineStyle="{StaticResource lineStyle}" VerticalLineStyle="{StaticResource lineStyle}" />
                             <syncfusion:ChartTrackBallBehavior />
                </syncfusion:SfChart.Behaviors>
                <syncfusion:SfChart.PrimaryAxis>
                    <syncfusion:CategoryAxis Interval="1">
                        <syncfusion:CategoryAxis.AxisLineStyle>
                            <Style TargetType="Line">
                                <Setter Property="Stroke" Value="#04bee0" />
                                <Setter Property="StrokeThickness" Value="2" />
                            </Style>
                        </syncfusion:CategoryAxis.AxisLineStyle>
                    </syncfusion:CategoryAxis>
                </syncfusion:SfChart.PrimaryAxis>
                <syncfusion:SfChart.SecondaryAxis>
                    <syncfusion:NumericalAxis Interval="100">
                        <syncfusion:NumericalAxis.AxisLineStyle>
                            <Style TargetType="Line">
                                <Setter Property="Stroke" Value="#04bee0" />
                                <Setter Property="StrokeThickness" Value="2" />
                            </Style>
                        </syncfusion:NumericalAxis.AxisLineStyle>
                    </syncfusion:NumericalAxis>
                </syncfusion:SfChart.SecondaryAxis>
                <syncfusion:LineSeries SegmentColorPath="SegmentColor">
                    <syncfusion:LineSeries.AdornmentsInfo>
                        <syncfusion:ChartAdornmentInfo SegmentLabelContent="LabelContentPath" ShowLabel="True">
                            <syncfusion:ChartAdornmentInfo.LabelTemplate>
                                <DataTemplate>
                                    <Ellipse
                                        Width="18"
                                        Height="18"
                                        Fill="{Binding Converter={StaticResource TBlockChartBrushConverter}}"
                                        StrokeThickness="1" />
                                </DataTemplate>
                            </syncfusion:ChartAdornmentInfo.LabelTemplate>
                        </syncfusion:ChartAdornmentInfo>
                    </syncfusion:LineSeries.AdornmentsInfo>
                </syncfusion:LineSeries>
            </syncfusion:SfChart>
        </Border>

7 Replies

SM Saravanan Madheswaran Syncfusion Team August 11, 2025 10:39 AM UTC


Hi Tom,

I noticed that no binding path has been set for the series, which means the same series is dynamically updated across the four collections you mentioned. You’re also looking to customize how the values are displayed in the template.

To clarify, ChartPointInfo serves as the data context for the trackball label template. You can bind any property from this class to the LabelTemplate. If all your model classes share the same structure, you can access the underlying business model using the Item property.

<DataTemplate>

           <Border Background = "DarkGreen" CornerRadius="5" BorderThickness="2" BorderBrush="Black" Width="50" Height="30">

               <TextBlock Text = "{Binding Item.Value }" Foreground="White" FontWeight="Bold"  HorizontalAlignment="Center" VerticalAlignment="Center"/>

           </Border>

       </DataTemplate>

 


Trackball in WPF Charts control | Syncfusion



TO Tom August 11, 2025 01:13 PM UTC

Hi Saravanan Madheswaran ,

I want to do like this,

How can I display so much information in one control?

TrackballTemplate or ToolTipTemplate, Can you give me an example?

Image_4137_1754917849911



NT Nitheeshkumar Thangaraj Syncfusion Team August 12, 2025 11:13 AM UTC

Hi Tom,

Thank you for providing the output image for further clarification. We would like to inform you that it is indeed possible to display multiple pieces of information in the TrackballTemplate of the Syncfusion WPF Chart control. 

 The ChartPointInfo class serves as the data context for the trackball label template. You can bind any property from this class to the template. If all your model classes share the same structure, you can conveniently access the underlying business model using the Item property.

 

Below is a breakdown of the implementation:

 

public class TBlockRealtimeChartModel

{

    public int Pole { get; set; }

    public double Position { get; set; }

    public int FaultCode { get; set; }

    public double Current { get; set; }

    public double UpperLimit { get; set; }

    public string Status { get; set; }

    public double Temperature { get; set; }

    public double LowerLimit { get; set; }

}


public class ChartViewModel

{

    public ObservableCollection RealtimeData { get; set; }

 

    public ChartViewModel()

    {

        RealtimeData = new ObservableCollection

        {

            new TBlockRealtimeChartModel { Pole = 1, Position = 580, FaultCode = 0, Current = 12, UpperLimit = 1831, Status = "Normal", Temperature = 25, LowerLimit = 0 },

            // Add more data points as needed

        };

    }

}



<syncfusion:SfChart.Resources>

   <ResourceDictionary>

  <DataTemplate x:Key="trackballTemplate">
<StackPanel Background="LightBlue" Margin="10">
<TextBlock Text="{Binding Item.Pole, StringFormat='Pole: {0}'}" />
<TextBlock Text="{Binding Item.Position, StringFormat='Position: {0} μm'}"/>
<TextBlock Text="{Binding Item.FaultCode, StringFormat='FaultCode: {0}'}" />
<TextBlock Text="{Binding Item.Current, StringFormat='Current: {0} mA'}"/>
<TextBlock Text="{Binding Item.UpperLimit, StringFormat='UpperLimit: {0} μm'}"/>
<TextBlock Text="{Binding Item.Status, StringFormat='Status: {0}'}" />
<TextBlock Text="{Binding Item.Temperature, StringFormat='Temperature: {0}°C'}"/>
<TextBlock Text="{Binding Item.LowerLimit, StringFormat='LowerLimit: {0} μm'}" />
</StackPanel>
</DataTemplate>

  </ResourceDictionary>
</syncfusion:SfChart.Resources>

 

<syncfusion:LineSeries ItemsSource="{Binding RealtimeData}"
                        XBindingPath="Pole"
                        YBindingPath="Position"
                        ShowTrackballInfo="True"
                        TrackBallLabelTemplate="{StaticResource trackballTemplate}"
                        />



 

Output:

 Screenshot 2025-08-12 134412.png

We hope this meets your requirement. If you have any further queries, please feel free to ask. We are happy to assist you.

 

Regards,

Nitheesh.

 




TO Tom replied to Nitheeshkumar Thangaraj August 26, 2025 06:39 AM UTC

How should I display the trackball information completely? Right now, after I restrict the height of the container where the chart is located, the following situation occurs.

        <DataTemplate x:Key="tBlockTrackballTemplate">
            <Border
                Width="300"
                Height="250"
                Background="CornflowerBlue"
                BorderBrush="CornflowerBlue"
                BorderThickness="1"
                CornerRadius="5">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="3*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock
                        Margin="10"
                        FontFamily="{StaticResource PingFang}"
                        FontSize="16"
                        FontWeight="Bold"
                        Foreground="White"
                        Text="{Binding Item.ID, StringFormat='电机编号: {0}'}" />
                    <TextBlock
                        Grid.Column="1"
                        Margin="10"
                        FontFamily="{StaticResource PingFang}"
                        FontSize="16"
                        FontWeight="Bold"
                        Foreground="White"
                        Text="{Binding Item.TBlockPosition, StringFormat='当前位置: {0}'}" />
                    <TextBlock
                        Grid.Row="1"
                        Margin="10"
                        FontFamily="{StaticResource PingFang}"
                        FontSize="16"
                        FontWeight="Bold"
                        Foreground="White"
                        Text="{Binding Item.Temperature, StringFormat='当前温度: {0}℃'}" />
                    <TextBlock
                        Grid.Row="1"
                        Grid.Column="1"
                        Margin="10"
                        FontFamily="{StaticResource PingFang}"
                        FontSize="16"
                        FontWeight="Bold"
                        Foreground="White"
                        Text="{Binding Item.Electric, StringFormat='当前电流: {0}mA'}" />
                    <TextBlock
                        Grid.Row="2"
                        Grid.ColumnSpan="2"
                        Margin="10"
                        FontFamily="{StaticResource PingFang}"
                        FontSize="16"
                        FontWeight="Bold"
                        Foreground="White"
                        Text="{Binding Item.DriveStatusMessage, StringFormat='当前状态: {0}'}" />
                    <TextBlock
                        Grid.Row="3"
                        Grid.ColumnSpan="2"
                        Margin="10"
                        FontFamily="{StaticResource PingFang}"
                        FontSize="16"
                        FontWeight="Bold"
                        Foreground="MediumVioletRed"
                        Text="{Binding Item.WaringMessage, StringFormat='报警信息: {0}'}"
                        TextWrapping="Wrap" />
                </Grid>
            </Border>
        </DataTemplate>

Image_3842_1756190167217



AJ Arul Jenith Berkmans Syncfusion Team August 27, 2025 11:32 AM UTC

Hi Tom,

 

Thank you for sharing your code snippet and output image.

 

We’d like to clarify the behavior of trackball label positioning in the chart. The label is dynamically positioned to the left or right and top, or bottom depending on the available space around the data point. However, the default priority is left for right or left option and top for bottom or top option. If there isn’t enough space in those directions, the label may still attempt to render in the priority position, which can result in cropping.

 

To avoid this scenario, we recommend reducing the height of the trackball label template or increasing the height of the chart control. This will help ensure that the labels are displayed fully without being clipped.

 

If you need any further assistance or would like help customizing the label template, feel free to contact us.

 

Best regards,

Arul Jenith B.



TO Tom replied to Arul Jenith Berkmans August 29, 2025 12:29 AM UTC

Is there a way to fix the position of the label?



PM Priyadharshni Murugan Syncfusion Team August 29, 2025 07:42 AM UTC

Hi Tom,

 

We understand your concern about fixing the trackball label position. The chart is designed to place the label dynamically based on the available space, which helps prevent overlapping or clipping in different data scenarios. Because this logic is handled internally, there is no option to force the label into a fixed position.

We realize this may not be the exact behavior you expected, but this design is intended to ensure consistent readability across all cases. Please let us know if you would like assistance with any other chart features.


Regards,

Priyadharshni M


Loader.
Up arrow icon