Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CombinedChart and data #3930

Closed
Magiguigui opened this issue Apr 4, 2019 · 1 comment
Closed

CombinedChart and data #3930

Magiguigui opened this issue Apr 4, 2019 · 1 comment

Comments

@Magiguigui
Copy link

What did you do?

I tried to create a CombinedChartView filled with one LineChart and one BarChart

What did you expect to happen?

Have a view with both chart

What happened instead?

No data were drawn until I setted manually the data to CombinedChartData

Charts Environment

Using Charts (3.2.2)
Using Xcode 10.1
Using Swift 4.2
Using iOS 12.1

Demo Project

var dataEntries1 = [ChartDataEntry]()
var dataEntries2 = [BarChartDataEntry]()

for (index, vals) in content.enumerated() {
    dataEntries1.append(ChartDataEntry(x: Double(index), y: Double(vals.$1)))
    dataEntries2.append(BarChartDataEntry(x: Double(index), y: Double(vals.$2)))
}

let dataSet1 = LineChartDataSet(values: dataEntries1, label: "Distance (km)")
    dataSet1.axisDependency = .left

    dataSet1.circleRadius = 5
    dataSet1.lineWidth = 2.0
    dataSet1.setColor(UIColor.orange.withAlphaComponent(0.5))
    dataSet1.setCircleColor(UIColor.orange)

    dataSet1.fillAlpha = 65 / 255.0

let dataSet2 = BarChartDataSet(values: dataEntries2, label: "Elevation (m)")
    dataSet2.axisDependency = .right

// Work
let data = CombinedChartData()
    data.lineData = LineChartData(dataSet: dataSet1)
    data.barData = BarChartData(dataSet: dataSet2)

// Doesn't work
let data = CombinedChartData(dataSets: [dataSet1, dataSet2])

self.chart.data = data
@liuxuan30
Copy link
Member

refer ChartsDemo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants