I followed a tutorial to create a chart in my project. I was successful in creating the chart, however, I am now trying to initialize it with two different series (or labels in the legend), to reflect two different types of data (The equivalent of having two lines in the line chart). I tried initializing the chart's data function with an array of Data Sets, but it wouldn't allow it. Can somebody provide some assistance? Here is my code:
labels = ["Income", "Expenses"] // This are now two values on the x-axis, I would like for them to be two different labels.
let totals = [986.25, 871.41]
setChart(labels, values: totals)
func setChart(dataPoints: [String], values: [Double]) {
barChartView.noDataText = "Please run the calculation to provide data for the charts"
var dataEntries: [BarChartDataEntry] = []
for i in 0..<dataPoints.count {
let dataEntry = BarChartDataEntry(value: values[i], xIndex: i)
dataEntries.append(dataEntry)
}
let chartDataSet = BarChartDataSet(yVals: dataEntries, label: "Units Sold")
let chartData = BarChartData(xVals: months, dataSet: chartDataSet)
barChartView.data = chartData
chartDataSet.colors = ChartColorTemplates.colorful()
barChartView.animate(yAxisDuration: 1.0, easingOption: .EaseInBounce)
}
Find a picture of the chart attached (Where it says Units Sold is where I'd like the labels to be).