Pre loader

LineAnnotation overlaps with X and Y axis labels

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

Hi scichart team,

i have LineAnnotations in my chart which overlaps with X and Y axis labels when i zoom and pan around the chart, can i make sure its visible range is similar to that of a series it should get clipped around the ends instead of overlapping on Axes

Thanks, regards

Version
v5.0+
  • You must to post comments
0
0

Hello,
You could pass the clipping property to an annotation via options.

So try EAnnotationClippingMode.SeriesViewRect, I believe this should give the desired result.
Let us know if it works on your side.

  • You must to post comments
0
0

Hi Jim,
I tried adding,
clipping : EAnnotationClippingMode.SeriesViewRect,
but the result was the same i wasnt able to clip the line annotation

  • Rahul Kathayat
    EAnnotationClippingMode works for TextAnnotation, but for LineAnnotation it fails and does not have any effect
  • Rahul Kathayat
    the bug is confirmed even if i pass SeriesViewRect, internally it takes surface view rect only, i have manually overridden it using a custom class which worked for me : export class ClippedLineAnnotation extends LineAnnotation { constructor(options?: ILineAnnotationOptions) { super(options); // Default to SeriesViewRect so it clips to the plot area out of the box this.clipping = EAnnotationClippingMode.SeriesViewRect; } public override drawWithContext( renderContext: any, xCalc: any, yCalc: any, seriesViewRect: any, // ← this is what the parent bug ignores surfaceViewRect: any, chartViewRect: any ): void { // Temporarily swap seriesViewRect into the slot the parent bug ignores. // We do this by monkey-patching getClippingRect for this one call so it // receives the correct first argument without duplicating all the label logic. const originalGetClippingRect = this.getClippingRect.bind(this); (this as any).getClippingRect = ( clipping: any, _wrongRect: any, // parent always passes surfaceViewRect here — ignore it svRect: any, cvRect: any ) => { // Pass seriesViewRect (from our closure) as the first rect instead return originalGetClippingRect(clipping, seriesViewRect, svRect, cvRect); }; try { super.drawWithContext(renderContext, xCalc, yCalc, seriesViewRect, surfaceViewRect, chartViewRect); } finally { // Always restore, even if super throws (this as any).getClippingRect = originalGetClippingRect; } } }
  • Jim Risen
    Hi Rahul, I’m glad you managed to create a workaround. I’m going to log this as a bug. https://abtsoftware.myjetbrains.com/youtrack/issue/SCJS-2554/LineAnnotation-clipping-ignored
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.