All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bstats.charts.SingleLineChart Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package org.bstats.charts;

import org.bstats.json.JsonObjectBuilder;

import java.util.concurrent.Callable;

public class SingleLineChart extends CustomChart {

    private final Callable callable;

    /**
     * Class constructor.
     *
     * @param chartId The id of the chart.
     * @param callable The callable which is used to request the chart data.
     */
    public SingleLineChart(String chartId, Callable callable) {
        super(chartId);
        this.callable = callable;
    }

    @Override
    protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
        int value = callable.call();
        if (value == 0) {
            // Null = skip the chart
            return null;
        }
        return new JsonObjectBuilder()
                .appendField("value", value)
                .build();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy