-
Notifications
You must be signed in to change notification settings - Fork 79
Custom Graphs
Hidendra edited this page Mar 7, 2012
·
12 revisions
Custom Graphs are one of the more powerful features of Metrics which allows you to submit your own, custom data and is automatically tracked and graphed. This allows you to create different kinds of graphs such as Line, Area, Column, and Pie graphs.
Here is an example using only the default graph:
try {
Metrics metrics = new Metrics(plugin);
// Plot the total amount of protections
metrics.addCustomData(new Metrics.Plotter("Total Protections") {
@Override
public int getValue() {
return physicalDatabase.getProtectionCount();
}
});
metrics.start();
} catch (IOException e) {
log(e.getMessage());
}
You can create multiple graphs very easily, for example the following:
try {
Metrics metrics = new Metrics(plugin);
// Construct a graph, which can be immediately used and considered as valid
Graph graph = metrics.createGraph("Percentage of weapons used");
// Diamond sword
graph.addPlotter(new Metrics.Plotter("Diamond Sword") {
@Override
public int getValue() {
return 4; // Number of players who used a diamond sword
}
});
// Iron sword
graph.addPlotter(new Metrics.Plotter("Iron Sword") {
@Override
public int getValue() {
return 17;
}
});
metrics.start();
} catch (IOException e) {
log(e.getMessage());
}