Pre loader

Scroll axis horizontally with few conditions

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

Answered
1
0

Hello everyone.

I have chart with adding data every second.

What i want to do:
– by dragging finger left, right – chart scrolls left and right (can go to past data, etc)
– by two fingers zoom gesture – it zooms (only horizontally with autorange by Y axis)
– i set a visible range limit to the right in this way: user can scroll to the right xMax to be in the middle (currently this part not working – and axis zooming, when i continue scrolling to the right)

I tried a lot of different modifiers, but none of them was ok.

My setup:

lineDataSeries.addObserver(new IDataSeriesObserver() {
            @Override
            public void onDataSeriesChanged(IDataSeries<?, ?> iDataSeries, int i) {

                long addTime = 30_000 * currentTimeframe;

                runOnUiThread(() -> {
                    DateRange dateRange = new DateRange();

                    dateRange.setMinMax(new Date(0), new Date(lineDataSeries.getXRange().getMax().getTime() + addTime));

                    mSciChartSurface.getXAxes().getDefault().setVisibleRangeLimit(dateRange);
                });
            }
        });

final DateAxis dateAxis = sciChartBuilder.newDateAxis()
            .withAutoRangeMode(AutoRange.Never)
            .withDrawMajorTicks(true)
            .withDrawMinorTicks(false)
            .withDrawMinorGridLines(false)
            .withAutoFitMarginalLabels(false)
            .withTextFormatting("HH:mm:ss")
            .build();
    dateAxis.setMinimalZoomConstrain(25_000L * currentTimeframe); // 25 - 300 points
    dateAxis.setMaximumZoomConstrain(300_000L * currentTimeframe);

final NumericAxis yAxis = sciChartBuilder.newNumericAxis()
            .withAutoRangeMode(AutoRange.Always)
            .withGrowBy(new DoubleRange(0.1d, 0.1d))
            .withTextFormatting("#.000000")
            .withAutoFitMarginalLabels(false)
            .withDrawMinorTicks(false)
            .withDrawMinorGridLines(false)
            .build();
    yAxis.setMinimalZoomConstrain(0d);

ModifierGroup additionalModifiers = sciChartBuilder.newModifierGroup()
            .withPinchZoomModifier().withXyDirection(Direction2D.XDirection).withScaleFactor(2).build()
            .withZoomPanModifier().withReceiveHandledEvents(true).withXyDirection(Direction2D.XDirection).withClipModeX(ClipMode.ClipAtMax).build()
            //.withZoomExtentsModifier().withReceiveHandledEvents(true).withXyDirection(Direction2D.XDirection).build()
           //
            .withXAxisDragModifier().withReceiveHandledEvents(true).withDragMode(AxisDragModifierBase.AxisDragMode.Pan).withClipModeX(ClipMode.ClipAtMax).build()
            //.withYAxisDragModifier().withReceiveHandledEvents(false).withDragMode(AxisDragModifierBase.AxisDragMode.Scale).build()
            .build();
Version
2.2.2.2424
Attachments
  • Yura Khariton
    Hi Vadim. Unfortunately I’m not sure that I understand what you’re trying to achieve. Can you provide more detailed description of desired behavior? Maybe you have some videos or gifs which can show it?
  • Kirey Vadim
    Hi Yura. Just realised the reason of such behaviour: lets say current Xmax in dataSet is 16:00:00, i use setVisibleRangeLimit to set this limit to 16:00:40 (+40 seconds of current max). When i scroll right (to see more data from future) – scrolling should be disabled. Instead chart starts to zoom, because i set dateAxis.setMinimalZoomConstrain(25_000L); (this means my Xaxis can be zoomed up to 25 seconds on full screen width). Can send a video if problem is still not clear. Thanks for helping.
  • Yura Khariton
    Video would be very helpful or maybe you can attach entire project so I could debug in on my PC to find out why this zoom occurs. Thanks in advance.
  • Kirey Vadim
    Added short video to post
  • You must to post comments
Best Answer
0
0

Hi Vadim,

Can you try to update to our latest nightly build ( v2.2.2.2433 ) and try to change clip mode target for ZoomPanModifier to VisibleRangeLimit so during scrolling VisibleRange will be clipped to VisibleRangeLimit because by default it clips VisibleRange to MaximumRange which could result zooming effect which I’ve seen on video:

sciChartBuilder.newModifierGroup()
                    .withZoomPanModifier()
                        .withReceiveHandledEvents(true)
                        .withXyDirection(Direction2D.XDirection)
                        .withClipModexTargetX(ClipModeTarget.VisibleRangeLimit)
                        .withClipModeX(ClipMode.ClipAtMax)
                        .build()
                    .build();

Best regards,
Yura

  • 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