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

Swift 3 - BarChartData, resetLabelsToSkip() and setLabelsToSkip(0) not working #1723

Closed
SergioSCF opened this issue Oct 26, 2016 · 4 comments

Comments

@SergioSCF
Copy link

SergioSCF commented Oct 26, 2016

Find for "ERROR HERE" to see all errors that I have now. Basically, are:

`

chartData = BarChartData(xVals: dataPoints, dataSet: chartDataSet) // ERROR HERE

vw.xAxis.resetLabelsToSkip() // ERROR HERE

vw.xAxis.setLabelsToSkip(0) // ERROR HERE

`

PS: I already read the issue #1474 and couldn't fix the error using the example code. Please help me with my code.

`

func setChart(_ view: ChartViewBase, dataPoints: [String], values: [Int]) {
    var dataEntries: [BarChartDataEntry] = []
    var corItem: [UIColor] = []

    for i in 0..<dataPoints.count {
        let dataEntry = BarChartDataEntry(x: Double(values[i]), yValues: [Double(i)])
        dataEntries.append(dataEntry)
        corItem.append(UIColor.green)
    }

    var chartDataSet = ChartDataSet()
    var chartData = ChartData()

    if let vw = view as? BarChartView {
        chartDataSet = BarChartDataSet(values: dataEntries, label: "Score")
        chartData = BarChartData(xVals: dataPoints, dataSet: chartDataSet) // ERROR HERE

        chartDataSet.colors = corItem
        vw.xAxis.labelPosition = .bottom

        if self.atleta.atletaID > 0 {
            vw.xAxis.labelRotationAngle = 0.0

            // Show all labels
            vw.xAxis.resetLabelsToSkip() // ERROR HERE

        } else {
            vw.xAxis.labelRotationAngle = -90.0

            // Show all labels
            vw.xAxis.setLabelsToSkip(0) // ERROR HERE
        }
    }

    view.data = chartData
}

`

Thank you so much!

@liuxuan30
Copy link
Member

Are you using Chart 3.0? It no longer exists. Read release notes carefully and #1688

@bb-git
Copy link

bb-git commented Dec 2, 2016

Is there a replacement? Or what can I do to have a lineChart display no y-value at a certain index?

@subashvaradhan
Copy link

Hi I am using charts version 3.0.1...
I know that setLabelsToSkip is not in the version 3.0.1, but i want to set it in my project to skip some indexes....,
Is there any alternate for setLabelsToSkip in the latest version?

Any help, thanks in advance.

@liuxuan30
Copy link
Member

liuxuan30 commented Dec 5, 2016

I guess not. Since x axis behaves like y axis now. You can override a bunch of methods to do so.
take a look at computeAxisValues(), this is where it generate x axis value labels. You can override it with your own implementations.

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

4 participants