var headerAndFilters = { headerType: "header-sc", // social club filtering header disabledFields: // disables header fields [ false, // platforms false, // locations false, // age false, // gamers true, // game-types false, // character false, // dates+builds ], }; var reportOptions = { restEndpoint: config.earningsStats, restEndpointAsync: config.earningsStatsAsync, multipleRequests: generateEndpoints, processFunction: calcTotals, isClickable: true, enablePNGExport: "content-description", enableCSVExport: "content-description", hasFriendlierNames: true, // 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 ($("#friendlier-names").is(":checked") && d.FriendlyName) ? d.FriendlyName : d.Name; }, lrMargin: 15, }, // This is the breakdown piechart breakdown: { legend: false, pieLabelsOutside: true, labelSunbeamLayout: true, donut: true, donutLabelsOutside: false, sortByValueDesc: true, getPieLabel: function(d) {return d.label}, getValuesArray: function(d) {return d.SubStats; }, // 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 ($("#friendlier-names").is(":checked") && d.FriendlyName) ? d.FriendlyName : d.Name; }, lrMargin: 15, // Pass the breakdown object (need to include label/values/metadata) getObjects: function(d) {return [d]; }, }, }; var radioButtonsPrefix = "earnings-radio"; function setReportOptions() { var label = $(":radio[name=" + radioButtonsPrefix + "]:checked + label").text(); var metric = $(":radio[name=" + radioButtonsPrefix + "]:checked").val().split("|")[0]; var unit = $(":radio[name=" + radioButtonsPrefix + "]:checked").val().split("|")[1]; reportOptions.main.title = label; reportOptions.main.unit = " " + unit; //reportOptions.breakdown.unit = reportOptions.main.title; reportOptions.main.getValue = function(d) { return d[metric]; }; 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; html += "" + "" + "" if (metric != "UniqueGamers") html += ""; else 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) + "%)") : "") + "
"; 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", radioButtonsPrefix) .attr("id", radioButtonsPrefix + "-1") .val("Count|times") .attr("checked", true) ) .append( $("