-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selection on bubble chart #654
Comments
I think this can be done by overriding |
sorry I should not close it right now - BTW, is this a scatter chart or bubble chart? |
UPDATE - I just tried ChartsDemo with bubble/scatter chart, I can choose any bubble on same xIndex without problems. The difference is that you only has one data set? |
Hi @liuxuan30 please let me explain better my problem. The problem, in fact, is when you have one data set with more than one value in the same xIndex e.g. in the BubbleChartViewController.m in the ChartDemo project, if you have change the method - (void)setDataCount:(int)count range:(double)range like following:
You will see something like this: (Maybe in a different color and with different entries 😝) You must be able to select just one of the bubbles and not the rest of them. I'll check the both methods that you told me. Thanks in advance. 🤓 P.D. The android library have the same problem. |
I have seen this issue. It is because the highlight method tries to guess the closest point based on the touch location but is wrong since it doesn't take the y position into consideration I think. I'd have to look into it but this is indeed a bug. I'd look at the highlight code for the bubble chart view. It might use a generic chart highlighter which might need to be changed. |
Thanks @petester42 for the quick response. I did a quick research, we have the method: internal func getHighlight(x x: Double, y: Double) -> ChartHighlight
According this they take in count the x and y just to select the dataSet but not the elements inside the dataSet and this working fine, but the bubble needs a method more like the one in the bar, spefically in the stacked bar. I mean internal func getStackedHighlight(old old: ChartHighlight?, set: BarChartDataSet, xIndex: Int, dataSetIndex: Int, yValue: Double) -> ChartHighlight?
Do you recommend to create a new BubbleChartHihlighter.swift file to implement a method like getClosestStackIndex above all the values with the same index? |
@lidgardo Yes I understand the problem, and overriding I am just not sure if it's valid/good that single data set can have entries inside with same xIndex for bubble charts. If we support this, we will support both multiple data sets + single data set scenarios that have same xIndex. |
Hi @liuxuan30 , @petester42 I've already fixed the issue, I've to modify a little bit the following classes:
I have to fix some code because the way that I'm adding the data sets force me to use the x-Axis axis with a continuing scale and not with discrete value as you already have, now I'm able to select multiple bubbles in the same x-Index. Just like this: _Selecting the second value_ _Selecting a value for different set and same x-Index_ I'll add mi changes ina PR just to see if you guys want to implement mi code on the API I'd be reaaly happy to be a contributor. |
Great 🎉. I'll review it when you send it in. |
Hi guys, I just test your latest version and I saw your improvements on the selection but I guess this still having troubles, I just modify the class - (void)setDataCount:(int)count range:(double)range{
.
.
.
for (int i = 0; i < count; i++)
{
double val = (double) (arc4random_uniform(range));
double size = (double) (arc4random_uniform(range));
[yVals1 addObject:[[BubbleChartDataEntry alloc] initWithXIndex:i%3 value:val size:size]];
val = (double) (arc4random_uniform(range));
size = (double) (arc4random_uniform(range));
[yVals2 addObject:[[BubbleChartDataEntry alloc] initWithXIndex:i%3 value:val size:size]];
val = (double) (arc4random_uniform(range));
size = (double) (arc4random_uniform(range));
[yVals3 addObject:[[BubbleChartDataEntry alloc] initWithXIndex:i%3 value:val size:size]];
}
.
.
.
} Then I got the following result: As you can see I'm not able to select all the bubbles on the axis 😞 I'll try to fix this issue following the changes that you did on the 8f82f60 Thanks in advance! 🐼 |
Yes, I'm 100% sure that is latest code and I guess that the problem is the following function, Also on the if (high.xIndex < minx || high.xIndex >= maxx)
{
continue
} I did a new branch changing the binary search for a simple for, and commented the condition above, with that, the API works like a charm, please check it. |
I'm not able to create succesfully the pull request 😓 but you can check on my fork. 🙂 the changes that I mentioned before. |
That condition is for not looping over highlight values which are not in the viewport. |
The touch problem still exists in bubble graph of charts framework.For same X value multiple Y values are present the single bubble is only selected for all the bubbles for that X value.Can you please update the code that needs to be changed in the swift files,since i am using this framework in my iOS project. |
How do I reopen the issue? The problem still exists in 3.3.0 |
Okay. I finally solved the problem. I did not understand sort properly. It should sort x first, then y. I did not see any sorting code in the example. What still confuses me is that in the scatter example, highlights will first responds to the closest x, but in my code, it will respond to the closest distance. |
@Andy1984 hey bro, i've seen you on the candle stick chart thread as well. when u mean sort, were u referring to a line of code like this : self.candleChartValues.sorted(by: { $0.x < $1.x })? or is it a different method or synthax? |
Hi All ios-charts users 😃.
First, congrats on all the work @PhilJay and @danielgindi put into these libraries. High quality products, both.
Then, I found the little bug in the bubble chart, the specific case is when you have more than one bubble which belongs at the same set and both has the same x position e.g. check the image below.
In the example, we have tree bubbles in the same x-position, I mean 121.2K. Now when I try to select one of them it seems that the API always select the same and I guess is the one in the middle.
So I suppose that the API only search at the first element of every set wich is near to the tap, but in my case, I need to search to the elements of the set. Do you have any idea how I can do this? or where I can start reading the code just to add the fix?
The text was updated successfully, but these errors were encountered: