Skip to content
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

Is it enable to keep the origin visible X Range when I appended more data #2198

Closed
aelam opened this issue Feb 24, 2017 · 2 comments
Closed

Comments

@aelam
Copy link
Contributor

aelam commented Feb 24, 2017

For example

  1. a DataSet with XIndex from 0 to 100, Set axis Range like below then I can see all data in Chart
 _chartView.xAxis.axisMinimum = 0;
 _chartView.xAxis.axisMaximum = 100;
  1. I append a group of data with XIndex from -100 to -1 to this DataSet. Then I change the XAxis Range like the below
 _chartView.xAxis.axisMinimum = -100;
 _chartView.xAxis.axisMaximum = 100;

here is the problem
If I change axisMinimum, axisMaximum like the step 2, I can zoom in/out, move left/right. But I lost the origin visible range
If I don't change I can keep the origin visible range, but the data from -100 to -1 won't be enable to scroll to be seen.

My current solution is keeping the origin axisMinimum, axisMaximum the origin values , when I scroll the chart, I change the axisMinimum, axisMaximum at the same time to keep the xAxisRange not changed.

I'm wondering if the best way is modify the matrix in the step 2 ?
I also notice that there are two not used ivar. are they used to track the origin position?

    fileprivate var _autoScaleLastLowestVisibleX: Double?
    fileprivate var _autoScaleLastHighestVisibleX: Double?
@liuxuan30
Copy link
Member

liuxuan30 commented Feb 27, 2017

I feel that you changed the data, and then change the chart property, and then you should call notifyDataSetChanged(), or you should set axisMaximum and then update the data to make sure the calculation reflect correctly. That's because setting data should call notifyDataSetChanged() automatically.

Can this solve your issue?

@aelam
Copy link
Contributor Author

aelam commented Feb 27, 2017

The main point is move to the origin place after appended points. I've tried like the step 2 and moveView and it works. I hope I am using the API correctly

@aelam aelam closed this as completed Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants