Pre loader

Draw method of CustomRenderableSeries not called when no points

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

0
0

I created a CustomRenderableSeries to put TextAnnotations on surface for every drawn point.

I discovered that Draw method is not called when no points are to be drawn in the visible range, so i can’t do any cleanup of the annotations i created in a previous pass.

Is there a way to force Draw method to be called anyway upon surface redraw (for example when zooming)?

Thank you

Version
6.0.0.12976
  • You must to post comments
0
0

This is by design unfortunately, RenderableSeries will not be drawn unless they have a DataSeries and data in it. That data must also be on-screen.

However you just said that you want to display text for every drawn point. So why not pass the data for every drawn point to the CustomRenderableSeries and use that data to position your text?

Best regards,
Andrew

  • You must to post comments
0
0

Can you explain your solution with a small piece of code?
I can’t understand your approach.

Thank you

  • You must to post comments
0
0

Here is my piece of code so you can see how i’m handling the drawing

        protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData)
    {
        base.Draw(renderContext, renderPassData);

        foreach (var a in track.Surface.Annotations.ToList())
        {
            Surface.Annotations.Remove(a);
        }

        // The data for this render pass
        var dataPointSeries = renderPassData.PointSeries as Point2DSeries;

        if (dataPointSeries == null || dataPointSeries.Count == 0) return;

        var xCalc = renderPassData.XCoordinateCalculator;

        // Iterate over the point series
        for (int i = 0; i < dataPointSeries.Count; i++)
        {
            // Get the X value
            var x = dataPointSeries.XValues[i];

            // Transform coordinate
            var xCoord = xCalc.GetCoordinate(x);
            if (xCoord >= 0 && xCoord < renderContext.ViewportSize.Height)
            {
                double yCoord = 0;

                var text = <get text from x value>

                var TextAnnotation = new TextAnnotation();
                TextAnnotation.CoordinateMode = AnnotationCoordinateMode.Relative;
                TextAnnotation.VerticalAnchorPoint = VerticalAnchorPoint.Top;
                TextAnnotation.X1 = xCoord / renderContext.ViewportSize.Height;
                TextAnnotation.Y1 = yCoord;
                TextAnnotation.Text = text;
                Surface.Annotations.Add(TextAnnotation);
            }
        }
    }

Surface is the current drawn surface.
This solution works well except when the method is not called because of empty data series or no points in the visibile range. In this case the annotations stay on the surface while they should be removed.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies