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, forgive me if this question has been asked and answered but I have not have been able to find an answer in my searches. I am trying to create a line chart in a TableViewCell using Swift in iOS. It appears the chart is working correct, however, when I first see the chart it doesn't display correctly.
If I tap on the chart it displays for an instant, but if I long press (I have set up no gesture recognizers) I then see the chart displayed correctly. (Other than the fact that it still says No chart data available)
The code I'm using is below. Any help you can give will be greatly appreciated!
lineChart.descriptionText = "";
lineChart.noDataTextDescription = "Data will be loaded soon."
lineChart.maxVisibleValueCount = 60
lineChart.pinchZoomEnabled = true
lineChart.drawGridBackgroundEnabled = false
lineChart.drawBordersEnabled = true
loadData()
}
func loadData(){
// 1 - creating an array of data entries
var yVals1 : [ChartDataEntry] = [ChartDataEntry]()
for i in 0 ..< allCheckIns.count {
let checkIn: CheckIn = allCheckIns[i]
yVals1.append(ChartDataEntry(value: checkIn.weight, xIndex: i))
}
// 2 - create a data set with our array
let set1: LineChartDataSet = LineChartDataSet(yVals: yVals1, label: "Progress")
set1.axisDependency = .Left // Line will correlate with left axis values
set1.setColor(UIColor.redColor().colorWithAlphaComponent(0.5)) // our line's opacity is 50%
set1.setCircleColor(UIColor.redColor()) // our circle will be dark red
set1.lineWidth = 2.0
set1.circleRadius = 6.0 // the radius of the node circle
set1.fillAlpha = 65 / 255.0
set1.fillColor = UIColor.redColor()
set1.highlightColor = UIColor.whiteColor()
set1.drawCircleHoleEnabled = true
//3 - create an array to store our LineChartDataSets
var dataSets : [LineChartDataSet] = [LineChartDataSet]()
dataSets.append(set1)
//4 - pass our months in for our x-axis label value along with our dataSets
let timeFormatter = NSDateFormatter()
timeFormatter.dateFormat = "MM-dd-YYYY"
var dates: [String] = []
for item in allCheckIns {
let dateToDisplay: String = timeFormatter.stringFromDate(item.date)
dates.append(dateToDisplay)
}
let data: LineChartData = LineChartData(xVals: dates, dataSets: dataSets)
data.setValueTextColor(UIColor.whiteColor())
//5 - finally set our data
self.lineChart.data = data
well, I think there is something wrong in your UITableViewCell synergy with displaying some content. And I think it's beyond this project scope.
What I would suggest is looking at the cell frame, chart view frame, and when the data start loading, when cell start to display, etc. Again, it most likely your table view cell logic issues.
Hi, forgive me if this question has been asked and answered but I have not have been able to find an answer in my searches. I am trying to create a line chart in a TableViewCell using Swift in iOS. It appears the chart is working correct, however, when I first see the chart it doesn't display correctly.
If I tap on the chart it displays for an instant, but if I long press (I have set up no gesture recognizers) I then see the chart displayed correctly. (Other than the fact that it still says No chart data available)
The code I'm using is below. Any help you can give will be greatly appreciated!
`//MARK: - Chart Stuff
func buildChart(){
lineChart.delegate = self;
// var myIndexPath: [NSIndexPath] = []
// myIndexPath.append(NSIndexPath(forRow: 0, inSection: 0))
// self.tableView.reloadRowsAtIndexPaths(myIndexPath, withRowAnimation: UITableViewRowAnimation.Fade)
`
The text was updated successfully, but these errors were encountered: