ivnsch / SwiftCharts

Easy to use and highly customizable charts library for iOS
Apache License 2.0
2.53k stars 410 forks source link

Barchart shows up off my View #329

Closed martheli closed 6 years ago

martheli commented 6 years ago

I have the following code set up to create a basic bar chart and I would like the chart to appear in my UIView called chartView that I created in the center of my view controller. When I run the app the bar chart appears in the bottom right corner of the screen.

  func setChart(data:[(String,Double)]) {

        let chartConfig = BarsChartConfig(
            valsAxisConfig: ChartAxisConfig(from: 0, to: 250, by: 20)
        )

        let frame = chartView.frame

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

        chartView.addSubview(chart.view)
        self.chart = chart

    }