Skip to content

Custom Plotters

Jerom van der Sar edited this page Mar 12, 2014 · 5 revisions

There are some handy utility plotters which may come of use when working with McStats metrics. Notably, BukkitLib features plotters for Donut-Style graphs as they aren't implemented in the default api. Examples of donut graphs are the default graphs "Java Version" and "Operating System" (Linky).

Below are some examples of how plotters may be used in a plugin.

try {

    final Metrics metrics = new Metrics(plugin);
    final Graph example = metrics.createGraph("Example");
    final Graph donutExample = metrics.createGraph("Donut");

    example.addPlotter(new FixedPlotter("Revision", 5)); // Fixed value

    // This can be used as an incremental module counter much like the one Essentials uses.
    if (antiSwear.isEnabled()) {
        example.addPlotter(new FixedPlotter("AntiSwear")); // Defaults to 1
    }

    donutExample.addPlotter(new DonutPlotter("Kills", "Sword") { // Parameters: Inner layer, Outter layer
        @Override
        public int getValue() {
            return 5; // Could be a dynamic value
        }
    });

    donutExample.addPlotter(new DonutPlotter("Kills", "Bow and Arrow") {
        @Override
        public int getValue() {
            return 23; // Could be a dynamic value
        }
    });

    // Combination of DonutPlotter and FixedPlotter.
    // Last value is optional and defaults to 1 like FixedPlotter.
    donutExample.addPlotter(new FixedDonutPlotter("MinorVersion", "MajorVersion", 4));

    metrics.start();
} catch (IOException ex) {
    plugin.logger.warning("Failed to submit metrics");
}

Previous: Using Metrics, Next: Concurrency

Clone this wiki locally