Hi
I have added 24 Line graphs for EEG. Now I want to display the name of each channels against each graph. I am using Y steeped graph which you are using for Vital signs display in example code. Can you please let me know how to t to display the name of each channels against each graph
Best Regards,
Aditya
- Aditya Kadambi asked 2 years ago
- last active 2 years ago
Hi
I have a line chart that has already been drawn and synced with a sound.
when we play sound, chart begin to scroll horizontally.
but problem is lagging when scrolling chart.
Is there a way to fix this problem?
private Runnable mRunnable = new Runnable() {
@Override
public void run() {
forceRunInPauseMode = false;
getActivity().runOnUiThread(() -> {
currentTime = (int) exoPlayer.getCurrentPosition();
binding.tvCurrentDuration.setText(MiliToTimeConverter.milliToTime(currentTime));
});
int currentRange = currentTime * 2;
if (!isDraw) {
DoubleValues xValues = new DoubleValues(Arrays.copyOfRange(xDoubleArray, 0, xDoubleArray.length - 1));
DoubleValues yValues = new DoubleValues(Arrays.copyOfRange(yDoubleArray, 0, yDoubleArray.length - 1));
DoubleSeries doubleSeries = new DoubleSeries(xValues, yValues);
lineData.append(doubleSeries.getxValues(), doubleSeries.getyValues());
isDraw = true;
}
xVisibleRange.setMinMax(currentRange - visibleInterval / 2, currentRange + visibleInterval / 2);
}
};
private void updateChart() {
schedule = scheduledExecutorService.scheduleWithFixedDelay(() -> {
if (!isPlaying && !forceRunInPauseMode)
return;
UpdateSuspender.using(binding.sciChart, mRunnable);
}, 0, TIME_INTERVAL, TimeUnit.MILLISECONDS);
}
private void pause() {
exoPlayer.setPlayWhenReady(false);
binding.ivPlay.setImageResource(R.drawable.ic_play);
if (schedule != null)
schedule.cancel(false);
}
private void initSciChart() {
isChartConfigured = true;
SciChartBuilder.init(getContext());
binding.sciChart.setBackgroundColor(getResources().getColor(R.color.colorTransparent));
// Obtain the SciChartBuilder instance
SciChartBuilder mSciChartBuilder = SciChartBuilder.instance();
//set border style
binding.sciChart.setRenderableSeriesAreaBorderStyle(null);
xVisibleRange = new DoubleRange();
// Create a numeric X axis
final IAxis xAxis = mSciChartBuilder.newNumericAxis()
.withVisibleRange(xVisibleRange)
.withGrowBy(new DoubleRange(0.25d * visibleInterval / totalDuration, 0.25d * visibleInterval / totalDuration))
.withAutoRangeMode(AutoRange.Never)
.build();
final IAxis yAxis = mSciChartBuilder.newNumericAxis()
.withVisibleRange(-1d, 1d)
.withAutoRangeMode(AutoRange.Never)
.build();
xAxis.setVisibleRangeChangeListener((iAxisCore, oldRange, newRange, isAnimating) -> {
if (!isPlaying) {
double c = ((newRange.getMinAsDouble() + newRange.getMaxAsDouble()) / 4);
getActivity().runOnUiThread(() -> binding.tvCurrentDuration.setText(MiliToTimeConverter.milliToTime((long) c)));
}
});
xAxis.setDrawMajorGridLines(false);
xAxis.setDrawMinorGridLines(false);
xAxis.setDrawMajorBands(false);
xAxis.setDrawMajorTicks(true);
xAxis.setDrawMinorTicks(true);
xAxis.setTickProvider(new CustomTickProvider());
xAxis.setMaxAutoTicks(MAX_AUTO_TICKS);
xAxis.setMinorsPerMajor(MINOR_PER_MAJOR);
xAxis.setVisibility(View.GONE);
yAxis.setDrawMajorGridLines(false);
yAxis.setDrawMinorGridLines(false);
yAxis.setDrawMajorBands(false);
yAxis.setDrawMajorTicks(false);
yAxis.setDrawMinorTicks(false);
yAxis.setTickProvider(new CustomTickProvider());
yAxis.setMaxAutoTicks(MAX_AUTO_TICKS);
yAxis.setMinorsPerMajor(MINOR_PER_MAJOR);
yAxis.setVisibility(View.GONE);
VerticalLineAnnotation verticalLine = mSciChartBuilder.newVerticalLineAnnotation()
.withX1(0.5) // black
.withStroke(new SolidPenStyle(ColorUtil.argb(250, 120, 126, 136), true, 1f, null))
.withCoordinateMode(AnnotationCoordinateMode.RelativeX)
.build();
ModifierGroup chartModifiers = mSciChartBuilder.newModifierGroup()
.withModifier(new GestureModifierBase() {
@Override
public void detach() {
super.detach();
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
// Scroll X
xAxis.scroll((-distanceX/2), ClipMode.ClipAtExtents);
return true;
}
})
.build();
lineData = mSciChartBuilder.newXyDataSeries(Double.class, Double.class).build();
XyDataSeries staticData = mSciChartBuilder.newXyDataSeries(Double.class, Double.class).build();
final FastLineRenderableSeries lineSeries = mSciChartBuilder.newLineSeries()
.withDataSeries(lineData)
//.withPointMarker(mSciChartBuilder.newPointMarker(new EllipsePointMarker()).withSize(7, 7).withStroke(0xFF006400, 1).withFill(0xFFFFFFFF).build())
.withPaletteProvider(new XYCustomPaletteProvider(ColorUtil.argb(255, 50, 153, 0))) // green
.withStrokeStyle(ColorUtil.argb(250, 120, 126, 136), 1f, true) // black
.build();
final IRenderableSeries staticLineSeries = mSciChartBuilder.newLineSeries()
.withDataSeries(staticData)
.withPaletteProvider(new XYCustomPaletteProvider(ColorUtil.argb(255, 50, 153, 0))) // green
.withStrokeStyle(ColorUtil.argb(250, 120, 126, 136), 1f, true) // black
.build();
DoubleValues xValues = new DoubleValues(Arrays.copyOfRange(xDoubleArray, 0, totalRange));
DoubleValues yValues = new DoubleValues(Arrays.copyOfRange(yDoubleArray, 0, totalRange));
DoubleSeries doubleSeries = new DoubleSeries(xValues, yValues);
binding.sciChart.getRenderableSeries().add(lineSeries);
binding.sciChart.getRenderableSeries().add(staticLineSeries);
binding.sciChart.setRenderSurface(new RenderSurface(getContext()));
Collections.addAll(binding.sciChart.getYAxes(), yAxis);
Collections.addAll(binding.sciChart.getXAxes(), xAxis);
Collections.addAll(binding.sciChart.getChartModifiers(), chartModifiers);
Collections.addAll(binding.sciChart.getAnnotations(), verticalLine);
staticData.append(doubleSeries.getxValues(), doubleSeries.getyValues());
lineData.setAcceptsUnsortedData(true);
begin();
}
- abolfazl ghanbari asked 3 years ago
- last active 3 years ago
Hi
I have a chart from a sound.
In xiaomi phones when resume chart after pause it, my line chart faces the severe lag.
In other phones my chart work well.
what should I do?
phone is (Xiaomi mi a3)
private void resume() {
forceRunInPauseMode = true;
mediaPlayer.seekTo(currentTime);
mediaPlayer.start();
completedState = false;
pauseState = false;
updateChart();
}
private void updateChart() {
schedule = scheduledExecutorService.scheduleWithFixedDelay(() -> {
if (mediaPlayer.isPlaying() || forceRunInPauseMode){
UpdateSuspender.using(binding.sciChart, mRunnable);
}
}, 0, TIME_INTERVAL, TimeUnit.MILLISECONDS);
}
private Runnable mRunnable = new Runnable() {
@Override
public void run() {
forceRunInPauseMode = false;
currentTime = mediaPlayer.getCurrentPosition();
currentRange = currentTime * 2;
getActivity().runOnUiThread(()->binding.tvCurrentDuration.setText(MiliToTimeConverter.milliToTime(currentTime)));
if (currentRange < 0)
currentRange = 0;
else if (currentRange > xDoubleArray.length - 1)
currentRange = xDoubleArray.length - 1;
if (!drawed) {
DoubleValues xValues = new DoubleValues(Arrays.copyOfRange(xDoubleArray, 0, xDoubleArray.length-1));
DoubleValues yValues = new DoubleValues(Arrays.copyOfRange(yDoubleArray, 0, yDoubleArray.length-1));
DoubleSeries doubleSeries = new DoubleSeries(xValues, yValues);
lineData.append(doubleSeries.getxValues(), doubleSeries.getyValues());
drawed = true;
}
xVisibleRange.setMinMax((double) (currentRange - visibleInterval / 2), (double) (currentRange + visibleInterval / 2));
}
};
- abolfazl ghanbari asked 3 years ago
- last active 3 years ago
issue resolved….it happened due to late initialization of super class instance for context.
- Praween Kumar asked 5 years ago
- last active 5 years ago
Hey There.
I am new to sciChart and i am in ahurry to develop a realtime ECG App which takes data from Bluetooth. Ignore the harware part. Can anyone kindly prove me source code of realtime ecg monitoring or realtime linechart.
Thanx in advance
- Gourav Sharma asked 5 years ago
- last active 5 years ago
I want to change the color of the fill bellow the chart(with blue using line chart,FastMountainRenderableSeries etc) but I have problem with defining the BrushStyle and it wont apply on chart(issue with color define-initPaint).Should I change the function ?or how to change default area color ?
- Guest asked 7 years ago
- last active 7 years ago