Search in sources :

Example 1 with Point

use of com.djrapitops.plan.delivery.rendering.json.graphs.line.Point in project Plan by plan-player-analytics.

the class MutatorFunctions method addMissing.

public static List<Point> addMissing(List<Point> points, LineGraph.GapStrategy gapStrategy) {
    if (points == null || points.isEmpty())
        return points;
    List<Point> filled = new ArrayList<>();
    Long lastX = null;
    for (Point point : points) {
        long date = (long) point.getX();
        if (lastX != null && date - lastX > gapStrategy.acceptableGapMs) {
            addMissing(lastX, date, filled, gapStrategy);
        }
        lastX = date;
        filled.add(point);
    }
    return filled;
}
Also used : Point(com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)

Example 2 with Point

use of com.djrapitops.plan.delivery.rendering.json.graphs.line.Point in project Plan by plan-player-analytics.

the class GraphJSONCreator method playersOnlineGraph.

public String playersOnlineGraph(ServerUUID serverUUID) {
    Database db = dbSystem.getDatabase();
    long now = System.currentTimeMillis();
    long halfYearAgo = now - TimeUnit.DAYS.toMillis(180L);
    List<Point> points = Lists.map(db.query(TPSQueries.fetchPlayersOnlineOfServer(halfYearAgo, now, serverUUID)), Point::fromDateObj);
    return "{\"playersOnline\":" + graphs.line().lineGraph(points).toHighChartsSeries() + ",\"color\":\"" + theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE) + "\"}";
}
Also used : Database(com.djrapitops.plan.storage.database.Database) Point(com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)

Example 3 with Point

use of com.djrapitops.plan.delivery.rendering.json.graphs.line.Point in project Plan by plan-player-analytics.

the class MutatorFunctions method addMissing.

private static void addMissing(long from, long to, List<Point> points, LineGraph.GapStrategy gapStrategy) {
    long iterate = from + gapStrategy.diffToFirstGapPointMs;
    while (iterate < to) {
        points.add(new Point(iterate, gapStrategy.fillWith));
        iterate += gapStrategy.fillFrequencyMs;
    }
}
Also used : Point(com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)

Aggregations

Point (com.djrapitops.plan.delivery.rendering.json.graphs.line.Point)3 Database (com.djrapitops.plan.storage.database.Database)1