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

3.0.0 - adding X Values to LineChartData no longer supported? #1808

Closed
adriansoghoian opened this issue Nov 8, 2016 · 4 comments
Closed

Comments

@adriansoghoian
Copy link

Hello,

I'm migrating from 2.2.4 to 3.0.0 and am having issues adding xValues (strings in my case) to the chartData object. Previously I was able to do:

// yData: [Double]
// xData: [String]

// Adds in y-value entries to the dataset
for i in 0..<ydata.count { 
    let dataEntry = ChartDataEntry(value: ydata[i], xIndex: i)
    self.lineChartDataSet!.addEntry(dataEntry)
}
        
// Adds dataset to the ChartData object
self.lineChartData!.addDataSet(self.lineChartDataSet)
        
// Adds in string x-values for corresponding indices
for i in 0..<xdata.count {
    self.lineChartData!.addXValue(xdata[i])
}

It seems like the process for adding in xValues has changed (which is my case are date strings, like "Jan 20").

I've scoured the documentation and release notes and have been banging my head on this for awhile. Does anyone have any guidance for how to implement this in 3.0.0?

Thanks very much!

@shorbenko
Copy link

Have you tried solution from ##1800?

@adriansoghoian
Copy link
Author

Nope I hadn't, thanks very much for referring me. Closing this out.

@liuxuan30
Copy link
Member

You can't in 3.0. It behaves like y axis now.

@adriansoghoian
Copy link
Author

adriansoghoian commented Nov 9, 2016

Note that if you have a chart that needs to dynamically redraw a new set of points (and corresponding string x-values), calling notifyDataSetChanged on the ChartView no longer worked for me.

Instead, before supplying the new data I explicitly call lineChartView.clearValues() and this seems to work. I suspect there's a performance penalty but if there is, it's not noticeable for my use case.

Hope this helps someone!

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

3 participants