From 6c57d86cc1146783d1da28d91a563831df440efd Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Tue, 29 Aug 2017 22:16:13 +0300 Subject: [PATCH] WorldPie for each session (DrillDown doesn't work for some reason) --- .../info/parsing/InspectPageParser.java | 16 ++++++++++++---- .../plan/utilities/html/HtmlStructure.java | 19 ++++++++++++++++++- .../html/graphs/WorldPieCreator.java | 9 +++++---- Plan/src/main/resources/js/worldPie.js | 6 ++++-- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index c5aa9beaf..392ad306e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -105,8 +105,16 @@ public class InspectPageParser { long playtimeDay = AnalysisUtils.getTotalPlaytime(sessionsDay); long playtimeWeek = AnalysisUtils.getTotalPlaytime(sessionsWeek); - addValue("sessionLengthLongestDay", FormatUtils.formatTimeAmount(sessionsDay.get(0).getLength())); - addValue("sessionLengthLongestWeek", FormatUtils.formatTimeAmount(sessionsWeek.get(0).getLength())); + if (!sessionsDay.isEmpty()) { + addValue("sessionLengthLongestDay", FormatUtils.formatTimeAmount(sessionsDay.get(0).getLength())); + } else { + addValue("sessionLengthLongestDay", "-"); + } + if (!sessionsWeek.isEmpty()) { + addValue("sessionLengthLongestWeek", FormatUtils.formatTimeAmount(sessionsWeek.get(0).getLength())); + } else { + addValue("sessionLengthLongestWeek", "-"); + } addValue("sessionCountDay", sessionCountDay); addValue("sessionCountWeek", sessionCountWeek); @@ -137,8 +145,8 @@ public class InspectPageParser { .sorted(new SessionLengthComparator()) .collect(Collectors.toList()); if (sessionsInLengthOrder.isEmpty()) { - addValue("sessionLengthMedian", "No Sessions"); - addValue("sessionLengthLongest", "No Sessions"); + addValue("sessionLengthMedian", "-"); + addValue("sessionLengthLongest", "-"); } else { Session medianSession = sessionsInLengthOrder.get(sessionsInLengthOrder.size() / 2); addValue("sessionLengthMedian", FormatUtils.formatTimeAmount(medianSession.getLength())); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index 2c734cb33..09087b721 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -7,8 +7,10 @@ package main.java.com.djrapitops.plan.utilities.html; import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils; +import main.java.com.djrapitops.plan.utilities.html.graphs.WorldPieCreator; import main.java.com.djrapitops.plan.utilities.html.tables.KillsTableCreator; +import java.io.FileNotFoundException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -82,7 +84,7 @@ public class HtmlStructure { return builder.toString(); } - public static String createSessionsTabContent(Map> sessions, List allSessions) { + public static String createSessionsTabContent(Map> sessions, List allSessions) throws FileNotFoundException { Map serverNameIDRelationMap = new HashMap<>(); for (Map.Entry> entry : sessions.entrySet()) { @@ -144,6 +146,21 @@ public class HtmlStructure { builder.append("") .append("
"); + String id = "worldPie" + session.getSessionStart(); + + builder.append("
"); + + String[] worldData = WorldPieCreator.createSeriesData(session.getWorldTimes()); + + builder.append(""); // TODO WorldTimes Pie // Session-col, Row, Session-Content, Session-column ends. diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java index 42f87c401..50f88f40b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java @@ -26,8 +26,10 @@ public class WorldPieCreator { int size = playtimePerWorld.size(); for (Map.Entry world : playtimePerWorld.entrySet()) { - seriesBuilder.append("{name:'").append(world.getKey()) - .append("',y:").append(world.getValue()); + String worldName = world.getKey(); + seriesBuilder.append("{name:'").append(worldName) + .append("',y:").append(world.getValue()) + .append(", drilldown: '").append(worldName).append("'"); seriesBuilder.append("}"); if (i < size - 1) { @@ -45,7 +47,7 @@ public class WorldPieCreator { } private static String createDrilldownData(WorldTimes worldTimes) { - StringBuilder drilldownBuilder = new StringBuilder("["); + StringBuilder drilldownBuilder = new StringBuilder(); int i = 0; Map gmTimesMap = worldTimes.getWorldTimes(); @@ -63,7 +65,6 @@ public class WorldPieCreator { } i++; } - drilldownBuilder.append("]"); return drilldownBuilder.toString(); } diff --git a/Plan/src/main/resources/js/worldPie.js b/Plan/src/main/resources/js/worldPie.js index 6050d81b7..96b8c2554 100644 --- a/Plan/src/main/resources/js/worldPie.js +++ b/Plan/src/main/resources/js/worldPie.js @@ -25,8 +25,10 @@ function worldPie(id, worldSeries, gmSeries) { return ''+this.point.name+': ' + formatTimeAmount(this.y) + '
('+this.percentage.toFixed(2)+'%)'; } }, - series: [worldSeries] - drilldown: {series: [gmSeries]} + series: [worldSeries], + drilldown: { + series: [gmSeries] + } }); }