{"action":"closed","issue":{"url":"https://api.github.com/repos/PhilJay/MPAndroidChart/issues/2145","repository_url":"https://api.github.com/repos/PhilJay/MPAndroidChart","labels_url":"https://api.github.com/repos/PhilJay/MPAndroidChart/issues/2145/labels{/name}","comments_url":"https://api.github.com/repos/PhilJay/MPAndroidChart/issues/2145/comments","events_url":"https://api.github.com/repos/PhilJay/MPAndroidChart/issues/2145/events","html_url":"https://github.com/PhilJay/MPAndroidChart/issues/2145","id":170825257,"number":2145,"title":"onValuedSelected not call at first click after reloading data on piechart","user":{"login":"smidaharoun","id":10530308,"avatar_url":"https://avatars.githubusercontent.com/u/10530308?v=3","gravatar_id":"","url":"https://api.github.com/users/smidaharoun","html_url":"https://github.com/smidaharoun","followers_url":"https://api.github.com/users/smidaharoun/followers","following_url":"https://api.github.com/users/smidaharoun/following{/other_user}","gists_url":"https://api.github.com/users/smidaharoun/gists{/gist_id}","starred_url":"https://api.github.com/users/smidaharoun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smidaharoun/subscriptions","organizations_url":"https://api.github.com/users/smidaharoun/orgs","repos_url":"https://api.github.com/users/smidaharoun/repos","events_url":"https://api.github.com/users/smidaharoun/events{/privacy}","received_events_url":"https://api.github.com/users/smidaharoun/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-12T08:45:08Z","updated_at":"2016-08-12T12:23:46Z","closed_at":"2016-08-12T12:23:46Z","body":"The first click on the piechart is not calling `onValueSelected` after reloading piechart data.\r\nCode : \r\n```\r\n        pieChart = (PieChart) findViewById(R.id.chart_budget);\r\n        pieChart.setDescription(\"\");\r\n        pieChart.setUsePercentValues(true);\r\n        pieChart.setDrawHoleEnabled(false);\r\n        pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {\r\n            @Override\r\n            public void onValueSelected(Entry e, Highlight h) {\r\n                buttonBack.setVisibility(View.VISIBLE);\r\n                int position =(int) h.getX();\r\n                reloadData(position);\r\n            }\r\n\r\n            @Override\r\n            public void onNothingSelected() {\r\n\r\n            }\r\n        });\r\n```\r\n\r\n\r\nreloadData method : \r\n\r\n\r\n```\r\n    private void reloadData(int position) {\r\n        if (currentBudget == null || backStackBudget == null || backStackBudget.size() == 0) {\r\n            currentBudget = listBudgets.get(position);\r\n            backStackBudget = new ArrayList<>();\r\n            backStackBudget.add(currentBudget);\r\n            setData(currentBudget.getBudgetChildren().size(), 100, currentBudget.getBudgetChildren());\r\n        }\r\n        else if (currentBudget.getBudgetChildren().get(position).getBudgetChildren()  != null && currentBudget.getBudgetChildren().get(position).getBudgetChildren().size() != 0) {\r\n            currentBudget = currentBudget.getBudgetChildren().get(position);\r\n            backStackBudget.add(currentBudget);\r\n            setData(currentBudget.getBudgetChildren().size(), 100, currentBudget.getBudgetChildren());\r\n        }\r\n    }\r\n```\r\n\r\n\r\nsetData method \r\n\r\n```\r\n    private void setData(int count, float range, List<Budget> list) {\r\n        float mult = range;\r\n        ArrayList<PieEntry> entries = new ArrayList<PieEntry>();\r\n        for (int i = 0; i < count ; i++) {\r\n            entries.add(new PieEntry((int) ((Double.parseDouble(list.get(i).getBudgetMontant()) * mult) + mult / 5), listBudgets.get(i % listBudgets.size())));\r\n        }\r\n\r\n        PieDataSet dataSet = new PieDataSet(entries, \"Election Results\");\r\n        dataSet.setSliceSpace(3f);\r\n        dataSet.setSelectionShift(5f);\r\n\r\n        getRandomColors(count);\r\n        dataSet.setColors(colors);\r\n\r\n        PieData data = new PieData(dataSet);\r\n        data.setDrawValues(false);\r\n        data.setValueFormatter(new PercentFormatter());\r\n\r\n        pieChart.setData(data);\r\n        pieChart.setDescription(\"\");\r\n        pieChart.setUsePercentValues(true);\r\n        pieChart.getLegend().setEnabled(false);\r\n        pieChart.setRotationEnabled(false);\r\n        pieChart.highlightValues(null);\r\n        pieChart.invalidate();\r\n    }\r\n```"}}
{"actor":{"display_login":"PhilJay"}}