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 cannot display float numbers but int. #1497

Closed
PanWangJ opened this issue Feb 22, 2016 · 2 comments
Closed

Barchart cannot display float numbers but int. #1497

PanWangJ opened this issue Feb 22, 2016 · 2 comments

Comments

@PanWangJ
Copy link

I'm trying to work with MPAndroidChart to draw a very simple BarChart, and this is my code:

private void createSaleGraph() {
    ArrayList<BarEntry> entries = new ArrayList<>();
    entries.add(new BarEntry(200f, 0));
    entries.add(new BarEntry(301f, 1));
    entries.add(new BarEntry(112f, 2));
    entries.add(new BarEntry(98f, 3));
    entries.add(new BarEntry(523.5f, 4));
    BarDataSet dataset = new BarDataSet(entries, "Sale Data");

    ArrayList<String> labels = new ArrayList<>();
    labels.add("02.01");
    labels.add("02.02");
    labels.add("02.11");
    labels.add("02.12");
    labels.add("02.17");

    BarData data = new BarData(labels, dataset);
    mBarChart.setDoubleTapToZoomEnabled(false);
    mBarChart.setDescription("");
    mBarChart.setNoDataText("No Data");
    mBarChart.setTouchEnabled(false);
    mBarChart.setClickable(false);
    mBarChart.setData(data);
}

The fifth date in the DataSet should be 523.5, but the graph always displays 524, don't know how to make it display 523.5 as it should be.

Please help! Thanks!

@hijamoya
Copy link

face the same issue

@keith30xi
Copy link

Did you try a custom ValueFormatter that knows how to display floating point numbers?
See The-ValueFormatter-interface

@PhilJay PhilJay closed this as completed Mar 17, 2016
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