Skip to content

Issue with press on combined chart entries #664

@Paget96

Description

@Paget96

java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 2 at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) at java.util.Objects.checkIndex(Objects.java:391) at java.util.ArrayList.get(ArrayList.java:434) at info.appdev.charting.data.CombinedData.getDataByIndex(CombinedData.kt:116) at info.appdev.charting.data.CombinedData.getEntryForHighlight(CombinedData.kt:137) at info.appdev.charting.charts.Chart.highlightValue(Chart.kt:542) at info.appdev.charting.listener.ChartTouchListener.performHighlight(ChartTouchListener.kt:67) at info.appdev.charting.listener.BarLineChartTouchListener.onSingleTapUp(BarLineChartTouchListener.kt:537) at android.view.GestureDetector.onTouchEvent(GestureDetector.java:786) at info.appdev.charting.listener.BarLineChartTouchListener.onTouch(BarLineChartTouchListener.kt:114) at info.appdev.charting.charts.BarLineChartBase.onTouchEvent(BarLineChartBase.kt:574) at android.view.View.performOnTouchCallback(View.java:16686) at android.view.View.dispatchTouchEvent(View.java:16639) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3145) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2808) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3158) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2826)

This is where issue happens:

    override fun getEntryForHighlight(highlight: Highlight): Entry? {
        if (highlight.dataIndex >= this.allData.size)
            return null

        val data: ChartData<*> = getDataByIndex(highlight.dataIndex)

        if (highlight.dataSetIndex >= data.dataSetCount)
            return null

        // The value of the highlighted entry could be NaN -
        //   if we are not interested in highlighting a specific value.
        val entries = data.getDataSetByIndex(highlight.dataSetIndex)!!
            .getEntriesForXValue(highlight.x)
        for (entry in entries!!) if (entry.y == highlight.y ||
            highlight.y.isNaN()
        ) return entry

        return null
    }

File path:
MPAndroidChart-4.1.2-sources.jar!\info\appdev\charting\data\CombinedData.kt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions