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

DrawValuesEnabled variable unreachable (Swift 4.2) #3665

Closed
Jordanwayne opened this issue Sep 28, 2018 · 4 comments
Closed

DrawValuesEnabled variable unreachable (Swift 4.2) #3665

Jordanwayne opened this issue Sep 28, 2018 · 4 comments

Comments

@Jordanwayne
Copy link

What did you do?

I wanted to implement PieCharts into my app without many of the labels associated. I tried many of the available functions but couldn't find any that would turn off the values (not just the value names) on the pie chart itself. Looking into the library, I found that if I set drawValues on line 335 of Source > Charts > Renderers > PieChartRenderer.swift to false (overriding dataSet.isDrawValuesEnabled) it achieves the solution I was looking for.

I imagine there is probably a function call that was meant to achieve this for the user but it appears in Swift 4.2 it isn't reachable anymore. I'm not sure of this fix but I thought I'd bring it to your attention.

What did you expect to happen?

I thought that by turning off drawEntryLabelsEnabled, it would disable both the label and the value from the pie chart.

What happened instead?

The value label remained and there didn't seem to be a function call that would disable them.

Charts Environment

Charts version/Branch/Commit Number:
Xcode version:
Swift version:
Platform(s) running Charts:
macOS version running Xcode:

Demo Project

@Jordanwayne Jordanwayne changed the title DrawValuesEnabled function unreachable (Swift 4.2) DrawValuesEnabled variable unreachable (Swift 4.2) Sep 28, 2018
@pmairoldi
Copy link
Collaborator

drawValuesEnabled would be the property that you would need to change but it does seem that setting that to false still keeps the label. Don't really know if this is a bug though. @liuxuan30 what do you think? Should we add a new option for the label or just use isDrawValuesEnabled for both value and label?

@pmairoldi
Copy link
Collaborator

To turn off both value and labels you can do the following:

chartDataSet.drawValuesEnabled = false
chart.drawEntryLabelsEnabled = false

@Jordanwayne
Copy link
Author

Ok thanks, I'll try that instead.

@liuxuan30 liuxuan30 reopened this Oct 9, 2018
@liuxuan30
Copy link
Member

liuxuan30 commented Oct 9, 2018

I don't think it's a bug. Pie chart value labels have both x and y value label:

                let drawXOutside = drawEntryLabels && xValuePosition == .outsideSlice
                let drawYOutside = drawValues && yValuePosition == .outsideSlice
                let drawXInside = drawEntryLabels && xValuePosition == .insideSlice
                let drawYInside = drawValues && yValuePosition == .insideSlice

drawEntryLabels seems only affect x values.

in the beginning of drawValues loop:

            if !drawValues && !drawEntryLabels && !dataSet.isDrawIconsEnabled
            {
                continue
            }

it's designed to let you can disable x and y entry label respectively. Check out the pie chart demo to toggle x and y values

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