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();
- Kirey Vadim asked 6 years ago
- last edited 6 years ago
-
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?
-
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.
-
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.
-
Added short video to post
- You must login to post comments
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
- Yura Khariton answered 6 years ago
-
Thanks, it worked
- You must login to post comments
Please login first to submit.