SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

My requirement is that the user interaction is very similar to the existing drag and drop features that SciCharts supports. The user moves the mouse over an anchor point, the mouse cursor changes, and then the user can rotate an annotation around the anchor point.

Any guidance you can provide would be helpful.

Version
Latest
  • You must to post comments
0
0

Hi there,

We don’t support this out of the box I’m afraid, so you’re going to have to add it.

It is possible to Rotate an annotation using RenderTransform or LayoutTransform. How effective these techniques are in practice for a dynamically user-rotated annotation I don’t know!

Another technique may be to create a CustomAnnotation and build your rotation behaviour into that.

Sorry that’s the best we can do at the moment. Hope it is helpful though,

Best regards,
Andrew

  • You must to post comments
0
0

Hi Andrew,

Just checking in if this is still supporting. We also come across similar requirement where we need to let the user to rotate box annotation.

Let me know if there is anything available out of the box.

Thanks.

  • Andrew
    Not at this time, no. You could potentially add the functionality yourself by having a LayoutTransform on the Annotation but this would be a solution in your code, not ours, and is untested
  • Parthiv Prajapti
    Hi Andrew, thanks for the response and it makes sense.I am trying to implement rotation behavior for the box annotation in my app. I am able to achieve that but the problem I am right now I am facing is, when I rotate the box, the original thumbs (for resizing the box there inside AdornerLayer canvas) are stick with their location only.Please check the image I have attached.So I do not know how to make the orignal adorner and thumbs by in sync when the box rotate.Also here is the code I have created for rotatedbox. It would be a great help if you can look into it.public class RotatedRactangle : BoxAnnotation { #region Variables private Canvas _adornerCanvas; private Thumb _rotateThumb; private double _initialAngle; private RotateTransform _rotateTransform; private Vector _startVector; private Point _centerPoint; private IAnnotationResizeAdorner _adorner; #endregion#region Constructor public RotatedRactangle() { // DefaultStyleKey = “RotatedRactangleStyle”; } #endregion#region Override Methods public override void OnApplyTemplate() { base.OnApplyTemplate(); this.RenderTransformOrigin = new Point(0.5d, 0.5d); }protected override void RemoveAdorners(Canvas adornerLayer) { //Delete any existing explicite added thumb. if (adornerLayer.Children.Count > 0) { for (int index = 0; index < adornerLayer.Children.Count; index++) { if (adornerLayer.Children[index] is Thumb childThumb) { _rotateThumb.DragDelta -= _rotateThumb_DragDelta; _rotateThumb.DragStarted -= _rotateThumb_DragStarted; adornerLayer.Children.Remove(childThumb); } } }base.RemoveAdorners(adornerLayer); }protected override void AddAdorners(Canvas adornerLayer) { _adornerCanvas = adornerLayer; base.AddAdorners(adornerLayer); _adorner = adornerLayer.Children[0] as IAnnotationResizeAdorner; if (adornerLayer.Children[1] is Thumb thumb) { _rotateThumb = new Thumb { Style = thumb.Style }; _rotateThumb.DragDelta += _rotateThumb_DragDelta; _rotateThumb.DragStarted += _rotateThumb_DragStarted; //adornerLayer.Children.Add(_rotateThumb); if(this.VisualChildrenCount == 1) this.AddChild(_rotateThumb);SetRotateThumbLocation(); } } public override void OnDragDelta() { base.OnDragDelta(); SetRotateThumbLocation(); }protected override void SetBasePoint(Point newPoint, int index, IAxis xAxis, IAxis yAxis) { Debug.WriteLine(index); base.SetBasePoint(newPoint, index, xAxis, yAxis); }protected override Size ArrangeOverride(Size arrangeBounds) { return base.ArrangeOverride(arrangeBounds); }#endregion#region Methods private void _rotateThumb_DragStarted(object sender, DragStartedEventArgs e) { _centerPoint = this.TranslatePoint( new Point(this.Width * this.RenderTransformOrigin.X, this.Height * this.RenderTransformOrigin.Y), _adornerCanvas);Point startPoint = Mouse.GetPosition(_adornerCanvas); _startVector = Point.Subtract(startPoint, _centerPoint);_rotateTransform = this.RenderTransform as RotateTransform; if (_rotateTransform == null) { RenderTransform = new RotateTransform(0); _initialAngle = 0; } else { _initialAngle = _rotateTransform.Angle; } }private void _rotateThumb_DragDelta(object sender, DragDeltaEventArgs e) { Point currentPoint = Mouse.GetPosition(_adornerCanvas); Vector deltaVector = Point.Subtract(currentPoint, _centerPoint);double angle = Vector.AngleBetween(_startVector, deltaVector);RotateTransform rotateTransform = this.RenderTransform as RotateTransform; rotateTransform.Angle = _initialAngle + Math.Round(angle, 0);_adorner.UpdatePositions(); SetRotateThumbLocation(); }private void SetRotateThumbLocation() { _rotateThumb.VerticalAlignment = VerticalAlignment.Center; _rotateThumb.HorizontalAlignment = HorizontalAlignment.Left; }private void UpdateAdornerLocation() {}#endregion}
  • Parthiv Prajapti
    Sorry for this unformatted comment above, I am not sure how to formate the code so it looks readable from the comment I have made. Also not able to attached image here. But I guess if you paste the code and run it, things will make sense, which I trying to convey here.Thanks.
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.