Pre loader

Tag: pause

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

1 vote
0 answers
4k views

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));
    }
};
0 votes
15k views

I would like a “Pause” button on my chart to temporarily suspend drawing updates, even while realtime data updates are still coming in to the databound DataSeries. Pressing the button again would re-enable drawing updates and show the data lines updated with all the data collected while drawing was previously paused.

Is there anything in the SciChart API to do this easily or would I need to do this manually (possibly by cloning the DataSeries when the chart is paused and databinding to the clones, then restoring the original binding when un-paused)?

Thanks!

Showing 2 results

Try SciChart Today

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

Start TrialCase Studies