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

Change color of Bar chart data label #2573

Closed
Zwaaan opened this issue Jul 2, 2017 · 3 comments
Closed

Change color of Bar chart data label #2573

Zwaaan opened this issue Jul 2, 2017 · 3 comments

Comments

@Zwaaan
Copy link

Zwaaan commented Jul 2, 2017

When I write this code:

let set = BarChartDataSet(values: entries, label: "Test")
set.colors = [UIColor.green]
set.valueTextColor = UIColor.white
set.valueFormatter = IntegerValueFormatter()
let data = BarChartData(dataSet: set)
chart.data = data

The small box under the graph is turned green, but the text that says "Test" is still a black color, I've tried to change the color and font in many ways with no success.

So how to I change the bar chart data label color/font?

img_3379

@liuxuan30
Copy link
Member

liuxuan30 commented Jul 4, 2017

    /// List representing all colors that are used for drawing the actual values for this DataSet
    open var valueColors = [NSUIColor]()

    /// the font for the value-text labels
    var valueFont: NSUIFont { get set }

how valueColors are being used:

    /// - returns: The color at the specified index that is used for drawing the values inside the chart. Uses modulus internally.
    open func valueTextColorAt(_ index: Int) -> NSUIColor
    {
        var index = index
        if index < 0
        {
            index = 0
        }
        return valueColors[index % valueColors.count]
    }

please check ChartsDemo.. it's all there, and drawValues()

@Zwaaan
Copy link
Author

Zwaaan commented Jul 4, 2017

@liuxuan30 This changes the color/font in the chart, but the Label under the chart is not changed and remains black and in default font.

@liuxuan30
Copy link
Member

do you mean the x axis values? The are the same idea.

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