You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to make my bar chart look like this
and this is what I currently am at
The problem I have is that there is the small grey line going through each of the bars. It appears to be some kind of gridline. I have tried disabling the grid lines and axes but nothing seems to work.
Here is my code ` var chartEntries = BarChartDataEntry
var times = [50,120,150,250,250,350,430,500]
let shows = ["The Wire \n \n ","Game of Thrones \n \n ","The Sopranos \n \n ","Breaking Bad \n \n ","Billions \n \n ","House of Cards \n \n ","Attack on Titan \n \n ", "Mad Men \n \n "]
for i in 0 ..< times.count {
let chartEntry = BarChartDataEntry(x:Double(i), y: Double(times[i]))
chartEntries.append(chartEntry)
//categories[i] = shows[i] + "\n" + String(times[i])
}
let chartDataSet = BarChartDataSet(values: chartEntries, label: "Categories")
let chartData = BarChartData(dataSet: chartDataSet)
//chartDataSet.colors = [UIColor.clear]
chartData.barWidth = 0.2
barChart.leftAxis.axisMinimum = 0
barChart.data = chartData
barChart.chartDescription?.text = ""
barChart.legend.enabled = false
barChart.xAxis.labelPosition = .bottomInside
barChart.leftAxis.enabled = false
barChart.rightAxis.enabled = false
barChart.drawValueAboveBarEnabled = true
barChart.xAxis.valueFormatter = IndexAxisValueFormatter(values:shows)
barChart.xAxis.granularity = 1
barChart.xAxis.drawAxisLineEnabled = false
barChart.drawGridBackgroundEnabled = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
for e in chartEntries{
let bounds = self.barChart.getBarBounds(entry: e)
let gradientLayer = CAGradientLayer()
gradientLayer.frame = bounds
gradientLayer.colors = [UIColor(red: 0, green:30,blue:189).cgColor , UIColor(red:2, green:201, blue:255).cgColor]
gradientLayer.startPoint = CGPoint(x: 0.0, y: 0.5)
gradientLayer.endPoint = CGPoint(x: 1.0, y: 0.5)
self.barChart.layer.addSublayer(gradientLayer)
}
}
`
Any help is greatly appreciated
The text was updated successfully, but these errors were encountered:
Hi, I'm trying to make my bar chart look like this


and this is what I currently am at
The problem I have is that there is the small grey line going through each of the bars. It appears to be some kind of gridline. I have tried disabling the grid lines and axes but nothing seems to work.
Here is my code ` var chartEntries = BarChartDataEntry
Any help is greatly appreciated
The text was updated successfully, but these errors were encountered: