6

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

Ciboulette
  • 145
  • 1
  • 2
  • 9

3 Answers3

9

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

levan
  • 440
  • 1
  • 8
  • 19
4

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.

Wingzero
  • 9,644
  • 10
  • 39
  • 80
  • https://stackoverflow.com/questions/45430461/how-to-add-marker-to-center-position-in-ios-charts-while-scrolling-horizontally – abh Aug 01 '17 at 06:37
  • Can you show me the code? It scaleX seems to be readonly property of ChartView now! – Prajeet Shrestha Nov 13 '19 at 10:36
  • Please look into this -https://stackoverflow.com/questions/62343054/how-to-manually-add-marker-in-swift-charts-at-fixed-point#62343054 – Amit Jun 12 '20 at 11:27
1

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