{"action":"closed","issue":{"url":"https://api.github.com/repos/PhilJay/MPAndroidChart/issues/1112","labels_url":"https://api.github.com/repos/PhilJay/MPAndroidChart/issues/1112/labels{/name}","comments_url":"https://api.github.com/repos/PhilJay/MPAndroidChart/issues/1112/comments","events_url":"https://api.github.com/repos/PhilJay/MPAndroidChart/issues/1112/events","html_url":"https://github.com/PhilJay/MPAndroidChart/issues/1112","id":111624412,"number":1112,"title":"Wrong Percentage calculation on PIE chart","user":{"login":"khushwaqt","id":15142925,"avatar_url":"https://avatars.githubusercontent.com/u/15142925?v=3","gravatar_id":"","url":"https://api.github.com/users/khushwaqt","html_url":"https://github.com/khushwaqt","followers_url":"https://api.github.com/users/khushwaqt/followers","following_url":"https://api.github.com/users/khushwaqt/following{/other_user}","gists_url":"https://api.github.com/users/khushwaqt/gists{/gist_id}","starred_url":"https://api.github.com/users/khushwaqt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khushwaqt/subscriptions","organizations_url":"https://api.github.com/users/khushwaqt/orgs","repos_url":"https://api.github.com/users/khushwaqt/repos","events_url":"https://api.github.com/users/khushwaqt/events{/privacy}","received_events_url":"https://api.github.com/users/khushwaqt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-15T14:07:37Z","updated_at":"2015-10-15T14:26:53Z","closed_at":"2015-10-15T14:26:53Z","body":"Hi, \r\nThank for such a library. \r\nI am facing an issue with PIE chart. \r\nI get wrongly calculated pie chart. \r\nI have two values Data Remaining and Total Data \r\nI have 6144 MB of total data and 3365 MB of remaining data, so the percentage should be 54% Used and 46 % remaining. But the PIE chart shows as 35% used and 64% remaining. \r\nHere is my code. \r\npublic void generateChartDataUsage(String totalVolume, String userVolume) {    \r\n\r\nmPieChartData.setUsePercentValues(true);\r\n\t\tmPieChartData.setHoleColor(Color.rgb(235, 235, 235));\r\n\t\tmPieChartData.setHoleColorTransparent(true);\r\n\t\tmPieChartData.setCenterTextTypeface(mFont);\r\n\t\tmPieChartData.setHoleRadius(0f);\r\n\t\tmPieChartData.setDescription(\"\");\r\n\t\tmPieChartData.setDrawCenterText(true);\r\n\t\tmPieChartData.setDrawHoleEnabled(false);\r\n\t\tmPieChartData.setRotationAngle(0);\r\n\t\tmPieChartData.setRotationEnabled(true);\r\n\t\tmPieChartData.setCenterText(totalVolume+\" MB\");\r\n\t\tmPieChartData.setCenterTextSize(20);\r\n\t\tmPieChartData.setCenterTextColor(Color.parseColor(\"#02438b\"));\r\n\t\tmPieChartData.setCenterTextTypeface(mFont);\r\n\t\tmPieChartData.animateXY(1500, 1500);\r\n\t\tsetChartDataUsage(Integer.parseInt(totalVolume),Integer.parseInt(userVolume));\r\n\t\tLegend l = mPieChartData.getLegend();\r\n\t\tl.setEnabled(false);\r\n}\r\nprivate void setChartDataUsage(int totalVolume, int usedVolume) {\r\n\r\n\t\tArrayList<Entry> yVals1 = new ArrayList<Entry>();\r\n\t\tyVals1.add(new Entry(totalVolume,1));\r\n\t\tyVals1.add(new Entry(usedVolume,2));\r\n\r\n\t\tArrayList<String> xVals = new ArrayList<String>();\r\n\t\txVals.add(\"% Remaining\");\r\n\t\txVals.add(\"% Used\");\r\n\t\tPieDataSet dataSet = new PieDataSet(yVals1, \"\");\r\n\t\tdataSet.setSliceSpace(3f);\r\n\r\n\t\tArrayList<Integer> colors = new ArrayList<Integer>();\r\n\t\tcolors.add(Color.parseColor(\"#63d957\"));//green 72e866 52c447\r\n\t\tcolors.add(Color.parseColor(\"#ed5653\"));//red f46d6d\r\n\t\tdataSet.setColors(colors);\r\n\r\n\t\tPieData data = new PieData(xVals, dataSet);\r\n\t\tdata.setValueFormatter(new PercentFormatter());\r\n\t\tdata.setValueTextSize(11f);\r\n\t\tdata.setValueTextColor(Color.parseColor(\"#FFFFFF\"));\r\n\t\tdata.setValueTypeface(mFont);\r\n\t\tmPieChartData.setData(data);\r\n\r\n\t\t// undo all highlights\r\n\t\tmPieChartData.highlightValues(null);\r\n\t\tmPieChartData.invalidate();\r\n\t}"}}