You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was working on a project and the problem I wanted to solve in my project is solve but I thought that if this thing is implemented then it would make many things very easy in some particular cases so I am putting it here.
If you want then you can get the value of selected point(x,y) poltteed on the chart via a protocol method chartValueSelected(args) like this-
func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) {
print(entry.x)//will print value of x coodinate for the selected point
print(entry.y)//will print value of y coodinate for the selected point
}
But what if someone wants to know the position of that x or y coordinate in the arrays used for plotting the values.
like suppose I am making a Line chart.
let a: [Double] = [2,4,3,2,5,9]
let b: [Double] = [10,20,30,40,50,60]
var dataEntries : [ChartDataEntry] = []
for index in 0..<b.count{
let dataEntry = ChartDataEntry(x: b[index], y: a[index])
dataEntries.append(dataEntry)
}
Now if we use chartValueSelected(args) we will ##get the values of a and b according to the plots but what if suppose I want to know the position of pointer with #respect to the value of coordinate which is selected.
like if I tap the coodinate (2,40) then I get the value 4 because it's on the 4th position or at 4th position in a or b technically.
I want to know that is there any way to do this or I have to tweak the library to extract this.
The text was updated successfully, but these errors were encountered:
Is there no interest in storing the index somewhere? I have a substantial number of data points in my chart, and I'm looking to highlight some data on another view when a value is highlighted (Supporting dragging, so potentially doing this many times per second).
Using indexOf and doing a linear scan of the array on each update is going to be very expensive.
Hi,
I was working on a project and the problem I wanted to solve in my project is solve but I thought that if this thing is implemented then it would make many things very easy in some particular cases so I am putting it here.
If you want then you can get the value of selected point(x,y) poltteed on the chart via a protocol method chartValueSelected(args) like this-
But what if someone wants to know the position of that x or y coordinate in the arrays used for plotting the values.
like suppose I am making a Line chart.
Now if we use chartValueSelected(args) we will ##get the values of a and b according to the plots but what if suppose I want to know the position of pointer with #respect to the value of coordinate which is selected.
like if I tap the coodinate (2,40) then I get the value 4 because it's on the 4th position or at 4th position in a or b technically.
I want to know that is there any way to do this or I have to tweak the library to extract this.
The text was updated successfully, but these errors were encountered: