WorldPie for each session (DrillDown doesn't work for some reason)

This commit is contained in:
Rsl1122 2017-08-29 22:16:13 +03:00
parent 75843e16ed
commit 6c57d86cc1
4 changed files with 39 additions and 11 deletions

View File

@ -105,8 +105,16 @@ public class InspectPageParser {
long playtimeDay = AnalysisUtils.getTotalPlaytime(sessionsDay); long playtimeDay = AnalysisUtils.getTotalPlaytime(sessionsDay);
long playtimeWeek = AnalysisUtils.getTotalPlaytime(sessionsWeek); long playtimeWeek = AnalysisUtils.getTotalPlaytime(sessionsWeek);
if (!sessionsDay.isEmpty()) {
addValue("sessionLengthLongestDay", FormatUtils.formatTimeAmount(sessionsDay.get(0).getLength())); addValue("sessionLengthLongestDay", FormatUtils.formatTimeAmount(sessionsDay.get(0).getLength()));
} else {
addValue("sessionLengthLongestDay", "-");
}
if (!sessionsWeek.isEmpty()) {
addValue("sessionLengthLongestWeek", FormatUtils.formatTimeAmount(sessionsWeek.get(0).getLength())); addValue("sessionLengthLongestWeek", FormatUtils.formatTimeAmount(sessionsWeek.get(0).getLength()));
} else {
addValue("sessionLengthLongestWeek", "-");
}
addValue("sessionCountDay", sessionCountDay); addValue("sessionCountDay", sessionCountDay);
addValue("sessionCountWeek", sessionCountWeek); addValue("sessionCountWeek", sessionCountWeek);
@ -137,8 +145,8 @@ public class InspectPageParser {
.sorted(new SessionLengthComparator()) .sorted(new SessionLengthComparator())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (sessionsInLengthOrder.isEmpty()) { if (sessionsInLengthOrder.isEmpty()) {
addValue("sessionLengthMedian", "No Sessions"); addValue("sessionLengthMedian", "-");
addValue("sessionLengthLongest", "No Sessions"); addValue("sessionLengthLongest", "-");
} else { } else {
Session medianSession = sessionsInLengthOrder.get(sessionsInLengthOrder.size() / 2); Session medianSession = sessionsInLengthOrder.get(sessionsInLengthOrder.size() / 2);
addValue("sessionLengthMedian", FormatUtils.formatTimeAmount(medianSession.getLength())); addValue("sessionLengthMedian", FormatUtils.formatTimeAmount(medianSession.getLength()));

View File

@ -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.data.Session;
import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils; 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 main.java.com.djrapitops.plan.utilities.html.tables.KillsTableCreator;
import java.io.FileNotFoundException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -82,7 +84,7 @@ public class HtmlStructure {
return builder.toString(); return builder.toString();
} }
public static String createSessionsTabContent(Map<String, List<Session>> sessions, List<Session> allSessions) { public static String createSessionsTabContent(Map<String, List<Session>> sessions, List<Session> allSessions) throws FileNotFoundException {
Map<Integer, String> serverNameIDRelationMap = new HashMap<>(); Map<Integer, String> serverNameIDRelationMap = new HashMap<>();
for (Map.Entry<String, List<Session>> entry : sessions.entrySet()) { for (Map.Entry<String, List<Session>> entry : sessions.entrySet()) {
@ -144,6 +146,21 @@ public class HtmlStructure {
builder.append("</div>") builder.append("</div>")
.append("<div class=\"session-col\">"); .append("<div class=\"session-col\">");
String id = "worldPie" + session.getSessionStart();
builder.append("<div id=\"").append(id).append("\" style=\"width: 100%; height: 400px;\"></div>");
String[] worldData = WorldPieCreator.createSeriesData(session.getWorldTimes());
builder.append("<script>")
.append("var ").append(id).append("series = {name:'World Playtime',colorByPoint:true,data:").append(worldData[0]).append("};")
.append("var ").append(id).append("gmseries = ").append(worldData[1]).append(";")
.append("$( document ).ready(function() {worldPie(")
.append(id).append(", ")
.append(id).append("series,")
.append(id).append("gmseries")
.append(");})")
.append("</script>");
// TODO WorldTimes Pie // TODO WorldTimes Pie
// Session-col, Row, Session-Content, Session-column ends. // Session-col, Row, Session-Content, Session-column ends.

View File

@ -26,8 +26,10 @@ public class WorldPieCreator {
int size = playtimePerWorld.size(); int size = playtimePerWorld.size();
for (Map.Entry<String, Long> world : playtimePerWorld.entrySet()) { for (Map.Entry<String, Long> world : playtimePerWorld.entrySet()) {
seriesBuilder.append("{name:'").append(world.getKey()) String worldName = world.getKey();
.append("',y:").append(world.getValue()); seriesBuilder.append("{name:'").append(worldName)
.append("',y:").append(world.getValue())
.append(", drilldown: '").append(worldName).append("'");
seriesBuilder.append("}"); seriesBuilder.append("}");
if (i < size - 1) { if (i < size - 1) {
@ -45,7 +47,7 @@ public class WorldPieCreator {
} }
private static String createDrilldownData(WorldTimes worldTimes) { private static String createDrilldownData(WorldTimes worldTimes) {
StringBuilder drilldownBuilder = new StringBuilder("["); StringBuilder drilldownBuilder = new StringBuilder();
int i = 0; int i = 0;
Map<String, GMTimes> gmTimesMap = worldTimes.getWorldTimes(); Map<String, GMTimes> gmTimesMap = worldTimes.getWorldTimes();
@ -63,7 +65,6 @@ public class WorldPieCreator {
} }
i++; i++;
} }
drilldownBuilder.append("]");
return drilldownBuilder.toString(); return drilldownBuilder.toString();
} }

View File

@ -25,8 +25,10 @@ function worldPie(id, worldSeries, gmSeries) {
return '<b>'+this.point.name+':</b> ' + formatTimeAmount(this.y) + '<br>('+this.percentage.toFixed(2)+'%)'; return '<b>'+this.point.name+':</b> ' + formatTimeAmount(this.y) + '<br>('+this.percentage.toFixed(2)+'%)';
} }
}, },
series: [worldSeries] series: [worldSeries],
drilldown: {series: [gmSeries]} drilldown: {
series: [gmSeries]
}
}); });
} }