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

zoom programatically, reset the zoom, set the highlight and moving the X-Axis and the Y-Axis to the middle #2529

Closed
MFJones21 opened this issue Jun 17, 2017 · 1 comment

Comments

@MFJones21
Copy link

The last few days I worked with your, absolutely awesome, iosCharts library and I am doing an App that Plots Graphs. I have a few funcitionalitys that I need bit could not find anywhere how to make happen.

  1. How can I reset the zoom reliably I tried multiple things that did not work. How do I do it properly ?

  2. How can I get the „from“ and to „values“ of the X and Y Axis when the view is getting zoomed

  3. How can I zoom programatically

  4. How can I programatically set the Highlight to a Point on X-Axis ?

  5. Is it possible to move the X-Axis and the Y-Axis to the middle of the Chart ? And if yes, how ?

Thanks a lot for your help in advance and for contributing to this awesome library !

@liuxuan30
Copy link
Member

liuxuan30 commented Jun 20, 2017

Most of your zoom requirement is implemented in ViewPortHandler so check it out like

open func resetZoom() -> CGAffineTransform
open func setZoom(scaleX: CGFloat, scaleY: CGFloat) -> CGAffineTransform

highlight can be code using highlight funcs inside ChartViewBase like

open func highlightValues(_ highs: [Highlight]?)
open func highlightValue(x: Double, y: Double, dataSetIndex: Int)

By default you can't move xAxis or yAxis to the middle. But there are some ways to do it:

  1. use ChartLimitLine to draw the line, if you don't need the labels.
  2. if you really need, then you have to change the code to draw them in the middle by overriding some methods inside AxisRenderer. To calculate the middle point, you can refer to UIView's center or contentRect's center.

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