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

Chart font size #24

Closed
achengscode opened this issue Aug 11, 2014 · 3 comments
Closed

Chart font size #24

achengscode opened this issue Aug 11, 2014 · 3 comments

Comments

@achengscode
Copy link

Is there anyway to set the font size that's used when the chart is being drawn?

It's frequently changing when I try it on different devices (some devices, it appears extremely small, on others it's extremely large).

Thanks

@PhilJay
Copy link
Owner

PhilJay commented Aug 11, 2014

Which fonts are you talking about?
x-axis labels? y-axis labels? legend? values inside the chart?

@achengscode
Copy link
Author

I'm talking about the values inside the chart (the y-values).

@PhilJay
Copy link
Owner

PhilJay commented Aug 11, 2014

Thank you for informing me, actually there is no possibility to directly set the font size :)

I will implement this right now and this feature will be included in the next update.
In the meantime, you can use a workaround like this:

Paint p = mChart.getPaint(Chart.PAINT_VALUES);
p.setTextSize(...);

mChart.setPaint(p, Chart.PAINT_VALUES);

EDIT: Unfortunately, the getPaint(...) feature is still buggy.

Another solution:

Copy this code snippet into the Chart.java file of the library and use it:

    /**
     * Sets the font size of the values that are drawn inside the chart.
     * 
     * @param size
     */
    public void setValueTextSize(float size) {
        mValuePaint.setTextSize(Utils.convertDpToPixel(size));
    }

Then call mChart.setValueTextSize(...) whenever you need it.

Also, the latest commit on the experimental branch already supports everything you need.

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