Skip to content

Instantly share code, notes, and snippets.

@sharish
Created August 31, 2015 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharish/52ec6ad79e9c3774d052 to your computer and use it in GitHub Desktop.
Save sharish/52ec6ad79e9c3774d052 to your computer and use it in GitHub Desktop.
final PieChart pie = (PieChart) this.findViewById(R.id.pie_chart);
float[] marks = {0.35f, 0.3f, 0.2f,0.15f};
String[] subjects = { "Physics", "Maths", "Chemistry", "CS"};
int[] colors = {Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW};
for (int i = 0; i < marks.length; i++) {
int color = colors[i % colors.length];
pie.addItem(subjects[i], marks[i], color);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment