-
-
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
Default zoom level at a position. #267
Comments
I found it's similar with my old post. What I was asking is to restore the scale/scroll offset state while jumping back the the chart. You can take a look at this:#226 |
Thanks for your quick response, I did saw that post before, but still not quit sure what to set to achieve the desired goal. I only have 1 VC so no need to carry over the 2nd VC. if there is same code will be greatly appreciated. |
I am not sure, but it's not a easy job to can come up a solution very quickly. If I were you I would first look at There are many APIs may help in You have to think about how to calculate the first/last 10 data points translation value given the scale level. I can guess if I could get the specific data point value given the scale level, try do some calculation to let the viewPortHandler.contentRect to only contain the data you need (via first data and last data point x value), so we can calculate the bounds and offset, and refresh the matrix. Welcome better answers:) I just give some seconds to think about it and continue my work. |
Of cause you need to understand how we create the matrix via: self._viewPortHandler.restrainViewPort(offsetLeft: left, offsetTop: top, offsetRight: right, offsetBottom: bottom)
prepareOffsetMatrix()
prepareValuePxMatrix() |
I was able to achieve this after playing with it a bit. It is actually pretty straight forward.
// set the max x data point to 10, which is what i wanted showing only 10 data points for the line or bar chart, from 100 data points. |
nice catch! |
If you do not want to 'lock' the view to only displaying 10 data points you could use the following in viewDidLoad. |
@spauldingim I was getting an issue when resetting my bar chart's data where it would zoom in too far when calling your code above again. Fixed it by first zooming out each time: |
First of all, great library. I wish i found this library sooner, I am still learning all the features. There is one basic feature, however I need some help to get it setup which is to plot a simple line chart or bar chart that has 100 data points, but instead of display all these 100 data point when the chart shows up, is there a way to default to show the last 10 data points or the first 10 data points and then user can scroll to view the rest. Is this feature available and how to set it up? Thnx
The text was updated successfully, but these errors were encountered: