I have a question about the scichart performance. I need to display a lot of data on the real time chart and above 2400000 values the chart crops and reacts very slowly. It was tested on Samsung s7. Does scichart handle that much data on devices? Is there any minimum phone performance requirements?
- al luk asked 5 years ago
- You must login to post comments
Hi there,
SciChart Android has been tested with up to 1,000,000 points on devices that are a lot older than the Samsung S7.
See SciChart Android Performance Comparison
This is a lot of data to handle, but I think that SciChart should be able to handle it.
Would you mind sharing some code how you have set up the chart? Our team can take a look and may be able to suggest improvements in configuration.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 5 years ago
- You must login to post comments
I am sending code where create a chart and add new values
private List<XyDataSeries> seriesData = new ArrayList<>();
private List<IRenderableSeries> series = new ArrayList<>();
private SciChartSurface surface;
private ModifierGroup chartModifiers;
private void initChart(Context context, LinearLayout chartLayout) {
surface = new VadiaChartSurface(context);
surface.setTheme(R.style.SciChart_SciChartv4DarkStyle);
surface.setRenderSurface(new RenderSurface(context));
if (chartLayout != null) {
chartLayout.addView(surface);
}
SciChartBuilder.init(context);
sciChartBuilder = SciChartBuilder.instance();
}
private void initAxis(String unit) {
final IAxis xAxis = sciChartBuilder.newNumericAxis().withLabelProvider(new TimeSpanLabelProvider()).withMaxAutoTicks(3).build();
final IAxis yAxis = sciChartBuilder.newNumericAxis().withVisibleRange(-1, 20).build();
Collections.addAll(surface.getYAxes(), yAxis);
Collections.addAll(surface.getXAxes(), xAxis);
}
private void initSeriesData(int fifoCapacity) {
seriesData.add(sciChartBuilder.newXyDataSeries(Long.class, Double.class).withFifoCapacity(fifoCapacity).withSeriesName(Channels.CH1.toString())
.build());
seriesData.add(sciChartBuilder.newXyDataSeries(Long.class, Double.class).withFifoCapacity(fifoCapacity).withSeriesName(Channels.CH2.toString())
.build());
seriesData.add(sciChartBuilder.newXyDataSeries(Long.class, Double.class).withFifoCapacity(fifoCapacity).withSeriesName(Channels.CH3.toString())
.build());
seriesData.add(sciChartBuilder.newXyDataSeries(Long.class, Double.class).withFifoCapacity(fifoCapacity).withSeriesName(Channels.CH4.toString())
.build());
}
private void initSeries() {
float strokeThickness = (int) (context.getResources().getDimension(R.dimen.pt_stroke_thickness) / context.getResources().getDisplayMetrics().density);
boolean antiAliasing = true;
series.add(sciChartBuilder.newLineSeries()
.withDataSeries(seriesData.get(0))
.withStrokeStyle(ColorUtil.Red, strokeThickness, antiAliasing)
.build());
series.add(sciChartBuilder.newLineSeries()
.withDataSeries(seriesData.get(1))
.withStrokeStyle(ColorUtil.Blue, strokeThickness, antiAliasing)
.build());
series.add(sciChartBuilder.newLineSeries()
.withDataSeries(seriesData.get(2))
.withStrokeStyle(ColorUtil.Green, strokeThickness, antiAliasing)
.build());
series.add(sciChartBuilder.newLineSeries()
.withDataSeries(seriesData.get(3))
.withStrokeStyle(ColorUtil.White, strokeThickness, antiAliasing)
.build());
for (int i = 0; i < series.size(); i++) {
series.get(i).setResamplingMode(ResamplingMode.MinMaxWithUnevenSpacing);
surface.getRenderableSeries().add(series.get(i));
}
}
private void initChartOverview() {
chartModifiers = sciChartBuilder.newModifierGroup()
.withPinchZoomModifier().withReceiveHandledEvents(true).withXyDirection(Direction2D.XDirection).build()
.withZoomPanModifier().withReceiveHandledEvents(true).withXyDirection(Direction2D.XDirection).withZoomExtentsY(false).build()
.withXAxisDragModifier().withReceiveHandledEvents(true).withDragMode(AxisDragModifierBase.AxisDragMode.Scale).withClipModex(ClipMode.None).build()
.build();
Collections.addAll(surface.getChartModifiers(), chartModifiers);
}
public void addDataToChannels(final VadiaData value) {
if (chartState == ChartState.Active)
UpdateSuspender.using(surface, new Runnable() {
@Override
public void run() {
seriesData.get(0).append(value.getVadiaDate(), value.getChannel1());
seriesData.get(1).append(value.getVadiaDate(), value.getChannel2());
seriesData.get(2).append(value.getVadiaDate(), value.getChannel3());
seriesData.get(3).append(value.getVadiaDate(), value.getChannel4());
surface.zoomExtentsX();
}
});
}
- al luk answered 5 years ago
-
Thank you. How is VadiaData defined? And How often is addDataToChannel called!
-
Well as I see you’ll get boxing/unboxing of 8 primitive values for each addDataToChannels() call. This could be the cause of poor performance. I would suggest you to use append() overload which accepts IValues which allows to avoid boxing/unboxing ( we use it in all our realtime examples such as https://www.scichart.com/example/android-chart-realtime-performance-demo/ ). Also you can take a look on this question ( https://stackoverflow.com/questions/39810816/scichart-android-real-time-graphing-how-to-maximize-graphing-speed/39953374#39953374 ) which contains some advices which allow to improve performance in case of realtime chart.
-
I’ll check it. Thank you.
- You must login to post comments
VadiaData stores the data received from Bluetooth. addDataToChannel is called 200 times per second
public class VadiaData {
private int vadiaNumber;
private long vadiaDate;
private double channel1;
private double channel2;
private double channel3;
private double channel4;
...
- al luk answered 5 years ago
- You must login to post comments
Please login first to submit.