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

How can I scroll to previous data? #3006

Closed
willard1218 opened this issue Nov 14, 2017 · 4 comments
Closed

How can I scroll to previous data? #3006

willard1218 opened this issue Nov 14, 2017 · 4 comments

Comments

@willard1218
Copy link

I have a frequently data.
Just like that:

nov-14-2017 14-49-38

The data will not update when I click stop monitor button.
how do I scroll from right to left to view previous data ?

The only way can scroll when I zoom out the chartView.
But I don't want to zoom out the chartView.

In my project, I will drop first data after 7th data enter,
because I would like the interval of xAxis are always same.
so the xAxis.axisMinimum will be change when data increase,
but I think that is correct way,
I don't like drop any data because when I click stop monitor button,
I would like scroll from right to left to view previous data.

So i would like :

  1. The interval of xAxis are always same.
  2. The visible data count <= 6, always
  3. when I click stop monitor button, I can scroll from right to left to view previous data.
@liuxuan30
Copy link
Member

liuxuan30 commented Nov 15, 2017

moveViewToAnimated and moveViewToX. or just modify the matrix and refresh (@objc open func refresh(newMatrix: CGAffineTransform, chart: ChartViewBase, invalidate: Bool) -> CGAffineTransform)

@willard1218
Copy link
Author

The data continues to come in,
if I don't drop first data after 7-th data come in,
The chart view will become:

nov-15-2017 10-57-21

but I would like when 7-th data come in, 1-st data will disappear in chartView,
when 8-th data come in, 2-nd data will disappear in chartView,

The max data count of chart view is 6.
and I click stop monitor button, I can scroll from right to left to view previous data.

How can I do this?

@liuxuan30
Copy link
Member

have you tried setVisibleXRange?

@willard1218
Copy link
Author

Finally, I got a solution.

let numOfVisiableData : CGFloat = 6
let scaleX = CGFloat(dataSet.values.count) / numOfVisiableData

chartView.setScaleMinima(scaleX, scaleY: 1.0)
chartView.xAxis.axisMinimum = xValueOfLastEntry - (numOfVisiableData - 1) * intervalOfX

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