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 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()));

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.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<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<>();
for (Map.Entry<String, List<Session>> entry : sessions.entrySet()) {
@ -144,6 +146,21 @@ public class HtmlStructure {
builder.append("</div>")
.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
// Session-col, Row, Session-Content, Session-column ends.

View File

@ -26,8 +26,10 @@ public class WorldPieCreator {
int size = playtimePerWorld.size();
for (Map.Entry<String, Long> 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<String, GMTimes> gmTimesMap = worldTimes.getWorldTimes();
@ -63,7 +65,6 @@ public class WorldPieCreator {
}
i++;
}
drilldownBuilder.append("]");
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)+'%)';
}
},
series: [worldSeries]
drilldown: {series: [gmSeries]}
series: [worldSeries],
drilldown: {
series: [gmSeries]
}
});
}