Force update trackball

Hello,

Is it possible to force update the trackball of a chart?

When the series have sparse values on the x-axis and you use the legend to hide a series, the trackball will still show the value of the hidden series when the mouse pointer re-enters the chart (atleast if it enters near the x value where it was when it left the chart).


Best regards,
Marcus

3 Replies 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team April 13, 2021 10:35 AM UTC

Hi Marcus, 
  
Greetings from Syncfusion support. 
  
We would like to let you know that we can refresh the trackball labels by force hiding it on Legend tapping. Please check the code snippet below.  
  
Xaml: 
<syncfusion:SfChart.Legend> 
        <syncfusion:ChartLegend MouseDown="legend1_MouseDown" ToggleSeriesVisibility="True"/> 
</syncfusion:SfChart.Legend> 
  
<syncfusion:SfChart.Behaviors> 
    <local:CustomTrackballBehavior x:Name="trackballBehavior"/> 
</syncfusion:SfChart.Behaviors> 
  
C#: 
private void legend1_MouseDown(object sender, MouseButtonEventArgs e) 
{ 
    trackballBehavior.Hide(); 
} 
. . . 
. . . 
public class CustomTrackballBehavior : ChartTrackBallBehavior 
{ 
    public void Hide() 
    { 
        IsActivated = false; 
        ClearItems(); 
        SetNativeInternalProperty(typeof(ChartTrackBallBehavior), this, string.Empty, "previousXLabel"); 
        SetNativeInternalProperty(typeof(ChartTrackBallBehavior), this, string.Empty, "previousYLabel"); 
    } 
  
    internal static void SetNativeInternalProperty(Type type, object obj, object value, string propertyName) 
    { 
        var properties = type.GetRuntimeProperties(); 
        foreach (var item in properties) 
        { 
            if (item.Name == propertyName) 
            { 
                item.SetValue(obj, value); 
                break; 
            } 
        } 
    } 
} 
  
Regards, 
Yuvaraj. 


Marked as answer

MJ Marcus johansson April 13, 2021 11:29 AM UTC

Hello,

Thanks a lot for the quick answer, it worked perfectly!

Best regards,
Marcus



YP Yuvaraj Palanisamy Syncfusion Team April 13, 2021 12:31 PM UTC

Hi Marcus, 
 
Thanks for your update. 
 
Regards, 
Yuvaraj. 


Loader.
Up arrow icon