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

Barchart fixed interval in left axis #2574

Closed
iad24 opened this issue Jul 3, 2017 · 1 comment
Closed

Barchart fixed interval in left axis #2574

iad24 opened this issue Jul 3, 2017 · 1 comment

Comments

@iad24
Copy link

iad24 commented Jul 3, 2017

Hello. I have a simple bar chart but I need the left axis values to be a multiple of 0.5.

Like this:
3.0 |
2.5 |
2.0 |
1.5 |
0.0 |

How to do this?

@liuxuan30
Copy link
Member

liuxuan30 commented Jul 4, 2017

use forceLabelEnabled and set the label count by:

    open func setLabelCount(_ count: Int, force: Bool)
    {
        self.labelCount = count
        forceLabelsEnabled = force
    }

related logic in open func computeAxisValues(min: Double, max: Double):

        ...
        // force label count
        if axis.isForceLabelsEnabled
        {
            interval = Double(range) / Double(labelCount - 1)
            
            // Ensure stops contains at least n elements.
            axis.entries.removeAll(keepingCapacity: true)
            axis.entries.reserveCapacity(labelCount)
            
            var v = yMin
            
            for _ in 0 ..< labelCount
            {
                axis.entries.append(v)
                v += interval
            }
            
            n = labelCount
        }
        ...

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