//set true for disabled filter var headerAndFilters = { headerType: "header-sc", // social club filtering header disabledFields: // disables header fields [ false, // platforms false, // locations false, // age false, // gamers false, // game-types false, // character false, // dates+builds ], }; var reportOptions = { restEndpoint: config.vehiclesStats, restEndpointAsync: config.vehiclesStatsAsync, multipleRequests: generateEndpoints, processFunction: calcTotals, isClickable: true, hasFriendlierNames: true, enablePNGExport: "content-description", enableCSVExport: "content-description", // 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: 10, }, // 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.PerVehicleStats; }, // 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: 10, // Pass the breakdown object (need to include label/values/metadata) getObjects: function(d) {return [d]; }, }, /* // function to get the name from the rest data getName: function(d) {return (d.CategoryName)}, // function to check if an entry has available detailed data hasDetailedData: function(d) {return ((d.PerVehicleStats)? true : false);}, getDetailedName: function(d) { return ($("#friendlier-names").is(":checked") && d.VehicleFriendlyName) ? d.VehicleFriendlyName : d.VehicleName; }, // function to get the list of sub objects getDetailedObjects: function(d) {return [{Items: d.PerVehicleStats}];}, //unit: "km", lrMargin: 0, */ }; var radioButtonsPrefix = "vehicles-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 ((unit == "km") ? d[metric]/config.aKmInMetres : 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 = "
| " + 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) + "%)") : "") + " |