Pre loader

Panning in DateAxis with a range outside the data range

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
0

I have this x axis:

private fun createxAxis(builder: SciChartBuilder, firstDay: Date?): DateAxis {
    val weekAgo = Calendar.getInstance().let {
        it.time = Date()
        it.add(Calendar.DATE, -6)
        it.time
    }
    val today = Calendar.getInstance().let {
        it.time = Date()
        it.add(Calendar.DATE, 1)
        it.time
    }
    val historicalFirst = if (firstDay != null) {
        Calendar.getInstance().let {
            it.time = firstDay
            it.add(Calendar.DAY_OF_MONTH, -1)
            it.time
        }
    } else {
        weekAgo
    }

    return builder.newDateAxis().apply {
        withDrawLabels(true)
        withDrawMajorBands(false)
        withDrawMajorTicks(false)
        withDrawMinorTicks(false)
        withTextFormatting("E")
        withTickLabelStyle(
            FontStyle(
                ResourcesCompat.getFont(context, R.font.proxima_nova_400),
                context.resources.getDimension(R.dimen._9sdp),
                resources.getColor(R.color.white, null),
                true
            )
        )
        withAutoFitMarginalLabels(false)
        withDrawMajorGridLines(true)
        withDrawMinorGridLines(false)
        isEnabled = true
        withVisibleRange(weekAgo, today)
        withVisibleRangeLimit(historicalFirst, today)
    }.build()
}

and this pan modifier:

    private class CustomXAxisDragModifier(
    val gestureCallback: WeakReference
) : XAxisDragModifier() {

    override fun performPan(xDelta: Float, yDelta: Float, isSecondHalf: Boolean, axis: IAxis) {
        super.performPan(xDelta, yDelta, isSecondHalf, axis)
        when (axis) {
            is DateAxis -> {
                gestureCallback.get()
                    ?.onVisibleRangeUpdated(axis.visibleRange.min, axis.visibleRange.max)
            }
        }
    }
}

val panModifier = CustomXAxisDragModifier(WeakReference(callback)).apply {
    dragMode = AxisDragModifierBase.AxisDragMode.Pan
    minTouchArea = 1000.0f
    clipModeX = ClipMode.ClipAtExtents
    clipModeTargetX = ClipModeTarget.VisibleRangeLimit
}
surface.chartModifiers.add(panModifier)

When I load this chart with data, it looks correct (see first screenshot). But the moment I try to drag it, the chart clips to the most recent data point (see second screenshot) instead of what I’m setting as the visible range limit. The most recent data point is a few days before today. How can I get the panning to clip at the visible range limit?

Version
4.4.0.4739
Images
  • Marcela Guerra
    Would appreciate some help with this still. I can’t find a workaround. Let me know if more details are needed. There doesn’t appear to be any reason why the visible range keeps jumping to only where the data is and can’t go beyond where the data is
  • Marcela Guerra
    One other piece of information: when i set the clip mode to “None” or “Stretch” the problem goes away, but then there’s the problem of the xaxis stretching when i try panning to the edge. Also, I’ve tried setting `clipModeTargetX` to all the other values and it’s still the same result. It always behaves as if `clipModeTargetX` is set to `DataRange`
  • Marcela Guerra
    Also, when i try printing out the visible range limit of the axis as I’m panning the values never change, but the chart always clips to DataRange instead
  • Marcela Guerra
    i found a workaround by using the ZoomPanModifier class instead. It doesn’t appear to have the same issue and will clip to visible range limits instead of only data range
  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.