-
-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Entries disappearing while zooming ScatterChart #718
Comments
I can confirm this issue. It seems to happen when there are fewer entries than x-values. (e.g. 500 x-values but only 25 entries) |
Related issue in ios-charts: ChartsOrg/Charts#130 |
I am facing the same problem with the line chart, is there any fix for this.... |
@PhilJay , @gjpc just found the source of this problem. All the people having this problem seem to be having one thing in common: They are giving In many places we are checking "is the value out of the viewport already?" -> "we can stop looping. break". Now if the values are not ordered, we are stopping prematurely. So we have to decide... Either:
Actually when the viewport is zoomed in on the right edge of the chart, we already having the "performance penalty" of extra matrix multiplications, as we are not breaking out of the loop for the values on the left. |
Yes, that seems like the reason why it's not working for some people, if by "not ordered" you mean "not ordered by x-index" (ascending). From what I have noticed, the matrix multiplications are not that time consuming. It's more the additional boundary checks and general runs through the drawing loops that decrease performance. I will do some extensive testing in the following days and then report back. If performance is too bad when the checks are removed, I suggest we stick with the option that the entries need to be ordered by x-index, what do you think Daniel? |
I think that's a compromise that everyone will be willing to take. It's much faster to just sort the yValues array once by the user [of the library] instead of looping through 10K values on each render loop. |
To be honest I think I already know that performance will be much worse if the checks are removed :-) |
I can also deduce that intuitively, but you know, you never know... |
The problem with sorting the x (or any) axis is that often the order the data is placed into an array is part of the dataset, let's call the order variable time instead of just an index. In a scatter plot tracking wilder beasts the X axis and Y axis are position and the index position of the coordinates is the time that the beast was at the point. The chart should be ready for multiple points where x,y are all equal, this happens when the wilder beast grazes. And yes, it always take longer to go through more data, but it is a necessary hit with some data sets. Perhaps setting a flag in a DataSet object's first scan of the data to let the renderers know it aint so. It may be advisable to just to go ahead and set the flag when realtime data manipulation occurs. |
@PhilJay Thanks for all the work you've put into this awesome library. If you decide to only allow sorted arrays for performance reasons, could you then make your |
For anyone also experiencing this issue you can fix it by doing the following: public class EntryComparator implements Comparator<Entry> {
@Override
public int compare(Entry entry1, Entry entry2) {
return entry1.getXIndex() - entry2.getXIndex();
}
} Use this class to sort the array containing the entries before passing it to the |
As noted above, ordering the data will lose information from some data sets. From Wikipedia: A scatter plot is used when a variable exists that is under the control of the experimenter. If a parameter exists that is systematically incremented and/or decremented by the other, it is called the control parameter or independent variable and is customarily plotted along the horizontal axis. The measured or dependent variable is customarily plotted along the vertical axis. If no dependent variable exists, either type of variable can be plotted on either axis and a scatter plot will illustrate only the degree of correlation (not causation) between two variables. |
I do not see how that description indicates that information will be lost. On Wed, Jun 17, 2015 at 5:52 PM, Gerard J. Cerchio <[email protected]
|
To go back to my example, a wilder beast will not only travel north and south over time but it will travel both east and west. The X axis is the east-west position of the animal on ground. if you order the east west data it will not reflect the actual travel of the animal, it will falsely show that the animal moves only in an easterly direction. |
Nobody wanted you to changed neither your X values or Y values, only to put On Wed, Jun 17, 2015 at 6:01 PM, Gerard J. Cerchio <[email protected]
|
If I ordered my x data point 538 would be to the right of point 535 not to the left as it was in the data |
We are going round and round. Nobody asked you to moved it on the x axis, but on the "i" axis. The index in the array. NOT the x-index, just index in the y-values array:
Instead of
Capiche? |
Non copiche, Daniel you are only showing the y value there where do I pump in the X value independent of the xIndex? I have to already use the xVals array to set the size of the area under study |
each entry has an x-index by itself, independent of its position inside the array |
And that X sets the size of the area that is under study, otherwise I can't control the area of the graph. |
Also there is only one set of xVals for multiple sets of yVals. In my data the yVals are not dependent on the xVals. קאפיש |
Man you are not listening.
|
LOL, no, I am reading. Where in IOS-Charts do I plot multiple yVals each associated with its own unique xVals? |
For each entry you pass an X index and a Y value. These are whatever you
like, you do not need to change anything until now.
The entries are in an array. The order of the entries in the array should
be in relation to their x-indexes.
So all you have to do is sort the array, nothing more. Do not touch the
Entries.
|
And sorting that array destroys the Sequence of when the data value was acquired. I am not only plotting Latitude (y) and Longitude (x) I am plotting time, time going in the only direction that time travels. |
It shouldn't destroy anything. Rendering is based on x indexes, not on |
Connect the data points by a line between each successive data point. That series of line segments will look very different for the sorted and unsorted cases. |
Let me chime in here:
Sorting the |
I thought you are talking about scatter charts. The only case where the |
@danielgindi Hmm, I think @gjpc didn't really complain about the visual appearance. That naturally stays the same whether the array is sorted or not. But I think @gjpc still cares about that information for other purposes besides visual appearance. |
@danielgindi oh yes, and count on that line enhancement when I have time to add it to the scatter plot. @TR4Android yes, you have encapsulated the problem. I'll look into |
@TR4Android Copying the array removes the visual information. That is why I modified the
to the base chart data set object. It hands over the index and data set so a more comprehensive value may be displayed in the value boxes on the chart; but that would take me some time because I have very little Swift under my belt. Also performance is not much of a problem, my average sized data set renders at blinding speed on my iPad Air, and we bio folks are an unusually patient bunch, sitting around in the weeds all day. And I always set my X axis to be larger than any value in my data set. |
@gjpc I have no experience on iOS whatsoever and thus cannot help you. On Android copying an array shouldn't remove the visual information as far as I know though, but that could be different in iOS. |
@danielgindi @TR4Android pushed the optional scatter lines to my branch https://github.com/gjpc/ios-charts |
I'm using a ScatterChart with cca. 10k xVals, and about 200 Entries. When I zoom, all entries on the graph disappear except the ones on the far right. When I drag to the far right, they suddenly appear (regardless of the zoom amount).
The text was updated successfully, but these errors were encountered: