// set true for disabled filter var headerAndFilters = { headerType: "header-sc-freemode", // social club filtering header disabledFields: // disables header fields [ false, // platforms false, // locations false, // age false, // gamers true, // game-types false, // dates+builds false, // mission categories false, // creators gamertags false, // created dates ], }; var matchTypesDict = getMatchTypesDict(); var freemodeCategoriesDict = getFreemodeCategoriesDict(); var rosPlatformsDict = getRosPlatformsDict(); var reportOptions = { restEndpoint: config.freemodeMissionsStats, restEndpointAsync: config.freemodeMissionsStatsAsync, multipleRequests: generateEndpoints, processFunction: calcTotals, isClickable: true, enableCSVExport: "content-description", availableMetrics: [ { name: "Time Playing ", metric: "TimeSpentPlaying", unit: "hours" }, { name: "Times Played ", metric: "TimesPlayed", unit: "times" }, { name: "Unique Players ", metric: "UniqueGamers", unit: "players" }, { name: "Total Players ", metric: "TotalGamers", unit: "players" }, ], /* hasExtraRestParams: [ { key: "MaxVariants", value: 1000, }, ], */ // This is a piechart main: { legend: true, pieLabelsOutside: true, labelSunbeamLayout: false, donut: true, donutLabelsOutside: true, sortByValueDesc: true, getPieLabel: function(d) { return this.title; }, getValuesArray: function(d) {return d.values; }, getMetadata: function(d) {return d.metadata; }, getName: function(d) {return matchTypesDict[d.MatchType];}, lrMargin: 25, }, // This is the breakdown piechart breakdown: { legend: false, pieLabelsOutside: false, labelSunbeamLayout: true, donut: false, donutLabelsOutside: false, sortByValueDesc: true, getPieLabel: function(d) {return d.BreakdownName}, getValuesArray: function(d) {return d.Items; }, // this is the values array inside the returned object getMetadata: function(d) {return d.metadata; }, // function to get the name from the rest data getName: function(d) {return (d.Name);}, lrMargin: 15, // Pass the breakdown object (need to include label/values/metadata) getObjects: function(d) { return ([{Items: d.Variants, BreakdownName: d.label}].concat(d.Breakdowns)) .map(function(b, i) { b["metadata"] = (i==0) ? ($.extend({}, d.metadata, {BreakdownMap : true})) : d.metadata; return b; }); }, showOnMap: function(d) {return (d && d.BreakdownMap) ? true : false;}, //show pie chart values on map when having that property getMapObjects: function(d) {return d}, drawMapByDefault: true, // draw the map on piechart load }, hasBreakdownMap: "breakdown-map", mapTooltipContent: function(d) { var content = "
" + d.Name + "


" + ""; content += (""); content += (""); content += "
Location: " + "(" + d.StartCoordinates.X + ", " + d.StartCoordinates.Y + ")" + "
UGC ID: " + d.UGCIdentifier + "
"; return content; } }; function setReportOptions() { var label = $(":radio[name=missions-freemode-radio]:checked + label").text(); var metric = $(":radio[name=missions-freemode-radio]:checked").val().split("|")[0]; var unit = $(":radio[name=missions-freemode-radio]:checked").val().split("|")[1]; reportOptions.main.title = label; reportOptions.main.unit = " " + unit; reportOptions.breakdown.unit = reportOptions.main.title; reportOptions.main.getValue = function(d) { if (!d.hasOwnProperty(metric)) return d["UniqueGamers"]; var value; if (unit == "hours") value = (d[metric]/config.anHourInSecs); else if (unit == "km") value = (d[metric]/config.aKmInMetres); else value = d[metric]; return value; }; reportOptions.breakdown.getValue = reportOptions.main.getValue; reportOptions.main.tooltipContent = function(key, y, e, graph) { var sum = d3.sum(graph.container.__data__[0].values, function(d) { return (!d.disabled) ? reportOptions.main.getValue(d) : 0; }); // Use e.value instead of y, y is a formated string and parsing to number fails var percentage = ((e.value/sum)*100).toFixed(2); var metadata = graph.container.__data__[0].metadata; var html = "

" + key + "


"; var commasFunc = (unit == "$") ? cashCommasFixed : commasFixed2; var ttUnit = (unit == "$") ? "" : unit; // Special case for waves if (e.point.hasOwnProperty("TimesReached")) { html += "" + "" + ""; } else { html += "
" + "Unique Players" + ":" + commasFunc(e.value) + " " + "players" + " (" + percentage + "%)" + "
" + "" + ""; if (metric != "UniqueGamers") html += ""; else html += ""; } if ((typeof e.point.TotalGamers !== "undefined") && (typeof e.point.TimesPlayed !== "undefined")) { html += ""; /* html += ""; */ } if ((typeof e.point.TimeSpentPlayingToCompletion !== "undefined") && e.point.TimesPlayedToCompletion) { html += ""; html += ""; } if (typeof e.point.AverageRating !== "undefined") html += ""; if (typeof e.point.UGCIdentifier !== "undefined") html += ""; if (typeof e.point.CreatedDate !== "undefined") html += ""; var creatorPlatform = (e.point.CreatorPlatform) ? (" (" + rosPlatformsDict[e.point.CreatorPlatform] + ")") : ""; if (typeof e.point.Creator !== "undefined") html += ""; if (typeof e.point.Category !== "undefined") html += ""; if (typeof e.point.IsPublished !== "undefined") html += ""; if (typeof e.point.TotalXP !== "undefined") html += ""; if ((typeof e.point.TotalXP !== "undefined") && (typeof e.point.TotalGamers !== "undefined")) html += ""; //if (typeof e.point.Description !== "undefined") // html += ""; html += "
" + label + ":" + commasFunc(e.value) + " " + ttUnit + ((metric != "UniqueGamers") ? (" (" + percentage + "%)") : "") + "
Total:" + commasFunc(sum) + " " + ttUnit + "
Online Players:" + commasFunc(metadata.onlinePlayers) + ((metadata.onlinePlayers) ? (" (" + commasFixed2((e.value/metadata.onlinePlayers)*100) + "%)") : "") + "
Average Players:" + commasFixed2(e.point.TotalGamers/e.point.TimesPlayed) + "
Total Players:" + commasFixed2(e.point.TotalGamers) + "
Users Quit:" + commasFixed2(e.point.TotalGamers - e.point.TimesPlayedToCompletion) + "
Average Completion Time:" + formatSecs(e.point.TimeSpentPlayingToCompletion/e.point.TimesPlayedToCompletion) + "
Average Rating:" + commasFixed2(e.point.AverageRating) + "
UGC ID:" + e.point.UGCIdentifier + "
Created At:" + parseJsonDate(e.point.CreatedDate).toUTCString() + "
Creator:" + e.point.Creator + creatorPlatform + "
Category:" + freemodeCategoriesDict[e.point.Category] + "
UGC Status:" + ((e.point.IsPublished) ? "Published" : "Saved") + "
Total RP:" + commasFixed2(e.point.TotalXP) + "
Average RP:" + commasFixed2(e.point.TotalXP / e.point.TotalGamers) + "
Description:" + e.point.Description + "
"; return html; }; reportOptions.breakdown.tooltipContent = reportOptions.main.tooltipContent; } function addMetrics() { $("#content-description") .empty() .append( $("
") .attr("id", "content-description-radiometrics") .css("float", "left") .append( $("") .attr("type", "radio") .attr("name", "missions-freemode-radio") .attr("id", "missions-freemode-radio-1") .val("TimeSpentPlaying|hours") .attr("checked", true) ) .append( $("