philackm / ScrollableGraphView

An adaptive scrollable graph view for iOS to visualise simple discrete datasets. Written in Swift.
MIT License
5.32k stars 472 forks source link

Is it possible to centre the graph when no scrolling is required? #158

Closed melwan closed 5 years ago

melwan commented 5 years ago

Thanks a lot for this great library.

I have a graphView with multiple graphs, but my data points (x-axis) are only 5. Is it possible in such a case to centre the graph, taking into consideration screen sizes? The uploaded screenshot shows how the graph is left-aligned currently.

I'm using the IB option. I added the graphView inside a UIView "masterView" and set constraints to that masterView. Even bars width is calculated based on the masterView width. Example: barRPlot.barWidth = masterGraphView.frame.size.width * 0.14

I tried: graphView.leftmostPointPadding = graphView.rightmostPointPadding but that did not work to centre the graphs.

I'm still learning Swift and iOS development, so any pointers in the right direction will be greatly appreciated.

Thanks.

screen shot 2018-11-22 at 8 46 54 pm