Во -первых, мне нужно получить доступ к индексу выбранной точки в диаграмме. Я устанавливаю данные в серии, как ниже: < /p>
series.keys = arrayListOf("x", "y", "index")
series.data = item.trends?.mapIndexed { index, it ->
arrayOf(it.realDate, it.value, index.toString())
}
< /code>
и напишите код ниже, чтобы обработать событие Click: < /p>
series.point = HIPoint()
series.point.events = HIEvents()
series.point.events.click = HIFunction(
HIConsumer { f: HIChartContext ->
onPointClick.invoke()
// Access the index, x, and y properties from the point
val xValue = f.getProperty("x")
val yValue = f.getProperty("y")
val index = f.getProperty("index")
// Create a message to display
val message =
"Clicked point - Index: $index , X: $xValue, Y: $yValue"
// Show a toast with the information
val toast: Toast =
Toast.makeText(context, message, Toast.LENGTH_SHORT)
toast.show()
},
arrayOf(
"x",
"y",
"index",
) // Specify the properties you want to access
)
< /code>
Toast показывает x и y экрана и возвращает NULL в качестве индекса. < /p>
Как я могу получить доступ к индексу?
Мне нужно получить доступ к индексу выбранной точки в диаграмме
Подробнее здесь: https://stackoverflow.com/questions/794 ... in-android