-
-
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
Why won't the viewport move to the last X value of my line chart? #3425
Comments
sorry this is a long text and I cannot read word by word. To be clear, I'm reading that your question is when your first show the chart, the last data entry is missing its dot and the label? When you feed empty data, and refill the data again, the last entry is displayed, despite the fact that your first image and last image data entries are not the same? To your code:
|
Thanks, liuxan30. I was finally able to figure it out. As you suggested, I am now calling Also, I was fetching the data that would be displayed on the charts before setting some of the chart properties that should be set prior to setting
|
I've been stuck for 4 days trying to figure out how to fix this and I'm out of ideas. I'm using version 3.1.1. of the framework and I'm having trouble getting the viewport to move far enough to the right to show the last value. If I segue to my ChartViewController and the current selection has data to display, it moves to a point in the chart that leaves 7 datapoints out of view to the right. However, if I then select another item that doesn't have any data and then select the previous item that has data, it correctly moves the chart so the last datapoint is visible:
When a selection is made, I fetch the appropriate data:
In
fetchLiftEvents()
I set thechartView.data
to nil if there's no data and this appears to be the only difference between what happens when I first segue to theChartViewController
and when select an item with no data and reselect the previous item:Both
generatexAxisDates(liftEvents: sortedLiftEvents)
andgenerateLineData(liftEvents: sortedLiftEvents)
are called inviewDidLoad()
, my point being that they're called when the view loads and when a new selection with data is chosen. I'm callingsetVisibleXRange(minXRange:maxXRange:)
ingenerateLineData(liftEvents:)
so it's always getting called as well:and
resetxAxis()
is only doing this:I've searched through the documentation and Issues on Github and looked at many related questions on SO, but I'm not able to get this to work. [This question][2] seems to be addressing the very same problem I'm having but after trying to apply the solution to my problem, it still persists.
Why would the chart not move all the way to the right when it first loads but then correctly move all the way to the right if I change the data and then reselect the very same data that wouldn't work correctly at first?
The text was updated successfully, but these errors were encountered: