Open Tim77277 opened 8 years ago
So, I am trying to draw a line chart on my app. And I found that somehow I could not assign the values to y axis. But x axis was totally fine. It assumed that the code might automatically generated the values from my data set.
my code is like this below
// simple arrays let data: [CGFloat] = [3, 4, -2, 11, 13, 15] let data2: [CGFloat] = [1, 3, 5, 13, 17, 20]
// simple line with custom x axis labels let xLabels: [String] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] let yLabels: [String] = ["0.1k", "0.2k", "0.3k", "0.4k", "0.5k", "0.6k"]
lineChart = LineChart() lineChart.animation.enabled = true lineChart.area = false lineChart.x.labels.visible = true lineChart.y.labels.visible = true
lineChart.y.axis.inset = 30 lineChart.x.axis.inset = 30
lineChart.x.grid.count = 5 lineChart.y.grid.count = 6
lineChart.x.labels.values = xLabels lineChart.y.labels.values = yLabels
lineChart.addLine(data) lineChart.addLine(data2)
lineChart.translatesAutoresizingMaskIntoConstraints = false lineChart.delegate = self chartView.addSubview(lineChart)
Same problem occurs, is there any solution for it?
So, I am trying to draw a line chart on my app. And I found that somehow I could not assign the values to y axis. But x axis was totally fine. It assumed that the code might automatically generated the values from my data set.
my code is like this below
// simple arrays let data: [CGFloat] = [3, 4, -2, 11, 13, 15] let data2: [CGFloat] = [1, 3, 5, 13, 17, 20]
// simple line with custom x axis labels let xLabels: [String] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] let yLabels: [String] = ["0.1k", "0.2k", "0.3k", "0.4k", "0.5k", "0.6k"]
lineChart = LineChart() lineChart.animation.enabled = true lineChart.area = false lineChart.x.labels.visible = true lineChart.y.labels.visible = true
lineChart.y.axis.inset = 30 lineChart.x.axis.inset = 30
lineChart.x.grid.count = 5 lineChart.y.grid.count = 6
lineChart.x.labels.values = xLabels lineChart.y.labels.values = yLabels
lineChart.addLine(data) lineChart.addLine(data2)
lineChart.translatesAutoresizingMaskIntoConstraints = false lineChart.delegate = self chartView.addSubview(lineChart)