Ciboulette
Ciboulette

Reputation: 165

Set an horizontal scroll to my Barchart in swift

I am using the Charts framework from Daniel Cohen Gindi which is great but:

I would like my barchart to scroll horizontally to see additional data.

I've tried to add a scroll view but it didn't worked. I also tried different value like

barChart.setVisibleXRangeMaximum(10)
barChart.moveViewToX(90)

but it didn't work.

Is anyone managed it ?

Fingers crossed

Upvotes: 8

Views: 9142

Answers (3)

user15007566
user15007566

Reputation: 71

I just found out, ordering matters for this to work. You need to call setVisibleXRangeMaximum after chartView.data = data and all kinds of attributes assigned for barChartView

Upvotes: 1

levan
levan

Reputation: 490

First set bar chart data and then call 'barChart.setVisibleXRangeMaximum(10)'

Upvotes: 10

Wingzero
Wingzero

Reputation: 9754

the scroll will only happen if you zoomed in. By default, all data are plotted on the canvas, so nothing to scroll.

You can try increase scaleX by code, to see if your code works.

Upvotes: 4

Related Questions