allow string values to be graphable in DS stats

This commit is contained in:
Stephen Birarda 2016-02-10 11:50:23 -08:00
parent a9fc69b4ac
commit 8598360f2e
5 changed files with 29 additions and 7 deletions

View file

@ -489,8 +489,13 @@ void AudioMixer::removeHRTFsForFinishedInjector(const QUuid& streamID) {
}
}
float AudioMixer::percentageForMixStats(int counter) {
return (_totalMixes > 0) ? (float(counter) / _totalMixes) * 100.0f : 0;
QString AudioMixer::percentageForMixStats(int counter) {
if (_totalMixes > 0) {
float mixPercentage = (float(counter) / _totalMixes) * 100.0f;
return QString::number(mixPercentage, 'f', 2);
} else {
return QString("0.0");
}
}
void AudioMixer::sendStatsPacket() {

View file

@ -71,7 +71,7 @@ private:
void perSecondActions();
float percentageForMixStats(int counter);
QString percentageForMixStats(int counter);
bool shouldMute(float quietestFrame);

View file

@ -92,6 +92,12 @@ tr.new-row {
background-color: #dff0d8;
}
.graphable-stat {
text-align: center;
color: #5286BC;
cursor: pointer;
}
.highchart-modal .modal-dialog {
width: 650px;
}

View file

@ -5,10 +5,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="/stats/css/json.human.css" rel="stylesheet" media="screen">
<link href="/css/style.css" rel="stylesheet" media="screen">
<link href="/css/sweetalert.css" rel="stylesheet" media="screen">
<link href="/css/bootstrap-switch.min.css" rel="stylesheet" media="screen">
<link href="/stats/css/json.human.css" rel="stylesheet" media="screen">
</head>
<body>

View file

@ -1,5 +1,5 @@
$(document).ready(function(){
var currentHighchart;
// setup a function to grab the nodeStats
@ -17,12 +17,22 @@ $(document).ready(function(){
var stats = JsonHuman.format(json);
$('#stats-container').html(stats);
// add the clickable class to anything that looks like a number
$('.jh-value span').each(function(val){
console.log(val);
if (!isNaN($(this).text())) {
// this looks like a number - give it the clickable class so we can get graphs for it
$(this).addClass('graphable-stat');
}
});
if (currentHighchart) {
// get the current time to set with the point
var x = (new Date()).getTime();
// get the last value using underscore-keypath
var y = _(json).valueForKeyPath(graphKeypath);
var y = Number(_(json).valueForKeyPath(graphKeypath));
// start shifting the chart once we hit 20 data points
var shift = currentHighchart.series[0].data.length > 20;
@ -91,7 +101,7 @@ $(document).ready(function(){
}
// handle clicks on numerical values - this lets the user show a line graph in a modal
$('#stats-container').on('click', '.jh-type-number', function(){
$('#stats-container').on('click', '.graphable-stat', function(){
graphKeypath = $(this).data('keypath');
// setup the new graph modal