0

So I have am using the SwiftCharts graph, and have it setup like this.

func roundToTens(_ x : Double) -> Int {
    return 10 * Int((x / 10.0).rounded(.awayFromZero))
}

func createChart(){
let chartConfig = BarsChartConfig(
    valsAxisConfig: ChartAxisConfig(from: 0, to: Double(roundToTens(maximum)), by: Double(roundToTens(maximum)/6))
)

let frame = view2.bounds


let chart = BarsChart(
    frame: frame,
    chartConfig: chartConfig,
    xTitle: "Categories",
    yTitle: "Y axis",
    bars: test,
    color: UIColor.red,
    barWidth: 20
)

self.chart = chart
view2.addSubview(chart.view)
self.view.addSubview(view2)
}

However, the graph ends up looking like this.

enter image description here

I tried fixing the bounds, by adding Margins to the bounds but all it did was make the graph look wrong. Is anyone familiar with the SwiftCharts framework and how I can centre the graph to the middle and make it overall smaller so that the top y-axis number is visible

Arnav GUPTA
  • 295
  • 1
  • 2
  • 17

0 Answers0