Skip to content

Instantly share code, notes, and snippets.

@Bastian
Last active May 13, 2021 17:44
Show Gist options
  • Save Bastian/474cf7eb3c2997d3cab73e560dce0caa to your computer and use it in GitHub Desktop.
Save Bastian/474cf7eb3c2997d3cab73e560dce0caa to your computer and use it in GitHub Desktop.
Bar chart example
@Override
public void onEnable() {
Metrics metrics = new Metrics(this);
// A simple bar chart for only one bar per category
metrics.addCustomChart(new SimpleBarChart("exampleBar", new Callable<Map<String, Integer>>() {
@Override
public Map<String, Integer> call() throws Exception {
Map<String, Integer> map = new HashMap<>();
map.put("Feature 1", 1);
return map;
}
}));
// An advanced bar for more then one bar per category
metrics.addCustomChart(new AdvancedBarChart("exampleBar", new Callable<Map<String, int[]>>() {
@Override
public Map<String, int[]> call() throws Exception {
Map<String, int[]> map = new HashMap<>();
map.put("Feature 1", new int[]{0,1});
map.put("Feature 2", new int[]{1,0});
return map;
}
}));
}
// If you use the Copy & Paste Metrics classes, use `Metrics.SimpleBarChart` or `Metrics.AdvancedBarChart` instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment