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
- You must login to post comments
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
- Yura Khariton answered 6 years ago
-
It works like a charm, thank you very much! I didn’t know about the existence of these type of wrappers
- You must login to post comments
Please login first to submit.