Pre loader

Append float array to XYDataSeries in Android

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

How can I append a float array to an XYDataSeries?

I’m developing an app with scichart. I receive buffers of 20 floats in a float[] type. How can I append this buffer to an XYDataSeries? The chart is updated in real time each time one Buffer is received with FIFO capacity.

What I need is something similar to:

void updateChart(final float[] a, final float[] b) {
    UpdateSuspender.using(surface, new Runnable() {
            @Override
            public void run() {
                // Append the new data received
                lineData.append(a,b);
                // Zoom series to fit the viewport to the x variable
                surface.zoomExtentsX();
            }
        });
}

Is this possible?
Thank you in advance

Version
Using Maven repository
  • You must to post comments
0
0

Hi Eduardo,

Thanks for your enquiry.

I would suggest you to use next code which uses FloatValues :

private IXyDataSeries<Float, Float> dataSeries;

void updateChart(final float[] a, final float[] b) {
    UpdateSuspender.using(surface, new Runnable() {
        @Override
        public void run() {
            // wrap primitive arrays into FloatValues
            final FloatValues xValues = new FloatValues(a);
            final FloatValues yValues = new FloatValues(b);

            // Append the new data received
            dataSeries.append(xValues, yValues);

            // Zoom series to fit the viewport to the x variable
            surface.zoomExtentsX();
        }
    });
}

We use similar approach in our real-time demos because it allows to avoid boxing/unboxing of primitive types caused by using generic TX/TY params in data series.

Is this suitable for you?

Best regards,
Yura

  • Eduardo Santamaría Vázquez
    It works like a charm, thank you very much! I didn’t know about the existence of these type of wrappers
  • You must to post comments
Showing 1 result
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