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
// 1 - creating an array of data entries
var dataEntries: [ChartDataEntry] = []
for i in 0..<values.count {
let dataEntry = ChartDataEntry(x: Double(i), y: values[i])
dataEntries.append(dataEntry)
}
// 2 - create a data set with our array
let lineChartDataSet = LineChartDataSet(values: dataEntries, label: "LINE CHART")
lineChartDataSet.setColor(UIColor.blue)
// lineChartDataSet.drawCubicEnabled = true
lineChartDataSet.mode = .cubicBezier
lineChartDataSet.drawCirclesEnabled = true
lineChartDataSet.lineWidth = 1.0
lineChartDataSet.circleRadius = 5.0
lineChartDataSet.drawFilledEnabled = true
lineChartDataSet.fillColor = .green
// lineChartDataSet.fillAlpha = 65 / 225.0
lineChartDataSet.highlightColor = UIColor.orange
lineChartDataSet.setCircleColor(UIColor.blue)
// lineChartDataSet.circleColors = [UIColor.red]
// lineChartDataSet.label = ""
lineChartDataSet.drawHorizontalHighlightIndicatorEnabled = true
//3 - create an array to store our LineChartDataSets
var dataSets = [IChartDataSet]()
dataSets.append(lineChartDataSet)
//4 - pass our months in for our x-axis label value along with our dataSets
let lineChartData = LineChartData(dataSets: dataSets)
lineChartData.setValueTextColor(UIColor.black)
// x-axis
lineChartView.xAxis.labelPosition = .bottom
lineChartView.xAxis.drawGridLinesEnabled = true
lineChartView.xAxis.granularity = 1.0
lineChartView.xAxis.setLabelCount(dataPoints.count, force: true)
lineChartView.gridBackgroundColor = UIColor.red
lineChartView.data = lineChartData
}
The text was updated successfully, but these errors were encountered:
Nallamsetty
changed the title
not able to get x-axis labels in line chart
not able to display x-axis labels like (jun, july) in line chart
Jun 13, 2018
here is the code, please help me...
fileprivate func setLineChart(_ lineChartView: LineChartView, dataPoints: [String], values: [Double]) {
The text was updated successfully, but these errors were encountered: