Pause or freeze trackball?
So I really like the clean interface of just having my line chart with a trackball showing all data points as the mouse is moved, however, it seems there is no way of pausing or freezing the trackball and because of this a user is unable to save or print the chart while including the information currently being shown by the trackball.
Hopefully this is something easy I am just overlooking.
SIGN IN To post a reply.
3 Replies
YP
Yuvaraj Palanisamy
Syncfusion Team
August 31, 2021 01:09 PM UTC
Greetings from Syncfusion.
We have analyzed your query and we have achieved your requirement “Freeze the trackball and exported image with Trackball” with the help of overriding the ChartTrackballBehavior and override the OnMouseLeave as per the below code example.
CodeSnippet:
|
<chart:SfChart.Behaviors>
<local:ChartTrackBallBehaviorExt x:Name="trackball" />
</chart:SfChart.Behaviors> |
|
public class ChartTrackBallBehaviorExt : ChartTrackBallBehavior
{
public Point TrackballPoint { get; set; }
public void Show(float x, float y)
{
IsActivated = true;
var point = new Point(x - this.ChartArea.SeriesClipRect.Left, y);
SetNativeInternalProperty(typeof(ChartTrackBallBehavior), this, point, "CurrentPoint");
base.OnPointerPositionChanged();
InvokeInternalMethod(typeof(ChartTrackBallBehavior), this, "Activate", IsActivated);
}
internal 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;
}
}
}
public object InvokeInternalMethod(Type type, object obj, string methodName, params object[] args)
{
var method = type.GetTypeInfo().GetDeclaredMethod(methodName);
return method != null ? method.Invoke(obj, args) : null;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
IsActivated = true;
Point point = e.GetPosition(this.ChartArea);
var trackball1 = (this.ChartArea.Behaviors[0] as ChartTrackBallBehaviorExt);
var diff1 = Math.Abs(trackball1.TrackballPoint.X - point.X);
UpdateTrackballPosition(trackball1, point);
}
private void UpdateTrackballPosition(ChartTrackBallBehaviorExt trackball, Point point)
{
trackball.TrackballPoint = point;
trackball.SetNativeInternalProperty(typeof(ChartTrackBallBehavior), this, point, "CurrentPoint");
trackball.OnPointerPositionChanged();
trackball.InvokeInternalMethod(typeof(ChartTrackBallBehavior), this, "Activate", IsActivated);
trackball.Show((float)point.X, (float)point.Y);
}
protected override void OnLayoutUpdated()
{
// base.OnLayoutUpdated();
}
} |
Also, we have attached the complete sample for your reference. Please find the sample from the below link.
Exported image:
For more details, please refer the below link
Regards,
Yuvaraj.
SC
Scott
September 1, 2021 07:07 PM UTC
That worked exactly as expected, thank you since I never would have figured that out.
YP
Yuvaraj Palanisamy
Syncfusion Team
September 2, 2021 02:08 PM UTC
Hi Scott,
Thank you for your update.
Please let us know if you have any further assistance.
Regards,
Yuvaraj.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SC Scott
- Aug 30, 2021 11:06 PM UTC
- Sep 2, 2021 02:08 PM UTC