Skip to content
Tyler Blair edited this page Jun 29, 2013 · 12 revisions

Custom Graphs are one of the more powerful features of Metrics which allows you to submit your own, custom data which is automatically tracked and graphed. This allows you to create different kinds of graphs such as Line, Area, Column, and Pie graphs without changing any of your code. You can have more than one graph.

NOTE: As of September 16, 2012 new graphs are hidden by default. If you want to show a graph that is hidden you will need to log into the admin portal and change it in there.


You can create multiple graphs very easily, for example the following:

The following graph would work good as a pie graph. At first it would show up as a line graph however can be changed. If only one server submitted data it would show 17/21=81% for Diamond Sword and 4/21=19% for Iron Sword. It simply sums up all the data for all servers. The numeric literals will usually be your own variable unless you use 1 (e.g. to denote a feature is enabled, for example).

try {
    Metrics metrics = new Metrics(plugin);

    Graph graph = metrics.createGraph("Percentage of weapons used");

    graph.addPlotter(new Metrics.Plotter("Diamond Sword") {

            @Override
            public int getValue() {
                    return 4; // Number of players who used a diamond sword
            }

    });

    graph.addPlotter(new Metrics.Plotter("Iron Sword") {

            @Override
            public int getValue() {
                    return 17;
            }

    });

    metrics.start();
} catch (IOException e) {
    log(e.getMessage());
}

See also

Clone this wiki locally