Skip to content

Commit

Permalink
#256 graph updates on match details
Browse files Browse the repository at this point in the history
  • Loading branch information
ebshimizu committed Dec 27, 2018
1 parent 7c32160 commit 73266db
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 3 deletions.
88 changes: 85 additions & 3 deletions js/match-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var teamOverallStatGraph, teamOverallStatGraphData;
var teamfightStatGraph, teamfightStatGraphData;
var teamCCGraph, teamCCGraphData;
var timePerTierGraphData, timePerTierGraph;
var heroUptimeGraphData, heroUptimeGraph;
var overallLevelGraphData, overallLevelGraph;
const xpBreakdownOpts = {
maintainAspectRatio: false,
Expand Down Expand Up @@ -2043,8 +2044,11 @@ function initTeamStatGraphs() {
},
options: {
tooltips: {
intersect: true,
mode: 'point'
callbacks : {
label: function(tooltipItem, data) {
return `${data.datasets[tooltipItem.datasetIndex].label}: ${formatSeconds(tooltipItem.yLabel)}`;
}
}
},
responsive: true,
maintainAspectRatio: false,
Expand All @@ -2064,7 +2068,12 @@ function initTeamStatGraphs() {
}],
yAxes: [{
ticks: {
fontColor: '#FFFFFF'
fontColor: '#FFFFFF',
callback: function(value, index, values) {
return formatSeconds(value);
},
stepSize: 60,
min: 0
},
gridLines: {
display: false
Expand All @@ -2074,6 +2083,56 @@ function initTeamStatGraphs() {
}
}

heroUptimeGraphData = {
type: 'bar',
data: {
labels: ['0', '1', '2', '3', '4', '5']
},
options: {
tooltips: {
callbacks : {
label: function(tooltipItem, data) {
return `${data.datasets[tooltipItem.datasetIndex].label}: ${formatSeconds(tooltipItem.yLabel)}`;
}
}
},
responsive: true,
maintainAspectRatio: false,
legend: {
labels: {
fontColor: '#FFFFFF'
}
},
scales: {
xAxes: [{
ticks: {
fontColor: '#FFFFFF'
},
gridLines: {
color: '#ababab'
},
scaleLabel: {
display: true,
labelString: 'Heroes Alive',
fontColor: '#FFFFFF'
}
}],
yAxes: [{
ticks: {
fontColor: '#FFFFFF',
callback: function(value, index, values) {
return formatSeconds(value);
},
min: 0
},
gridLines: {
display: false
}
}]
}
}
};

teamfightStatGraphData = {
type: 'horizontalBar',
data: {
Expand Down Expand Up @@ -2158,6 +2217,7 @@ function initTeamStatGraphs() {
teamfightStatGraph = new Chart($('#match-detail-teamfight-numbers'), teamfightStatGraphData);
teamCCGraph = new Chart($('#match-detail-team-cc'), teamCCGraphData);
timePerTierGraph = new Chart($('#match-detail-time-per-tier'), timePerTierGraphData);
heroUptimeGraph = new Chart($('#match-detail-hero-uptime'), heroUptimeGraphData);
}

function loadTeamStats() {
Expand All @@ -2170,6 +2230,7 @@ function drawTeamStatGraphs() {
teamfightStatGraphData.data.datasets = [];
teamCCGraphData.data.datasets = [];
timePerTierGraphData.data.datasets = [];
heroUptimeGraphData.data.datasets = [];

// since it's stacked i can just kinda dump everything in the right plcae hopefully
var blueCt = 0;
Expand Down Expand Up @@ -2251,6 +2312,18 @@ function drawTeamStatGraphs() {
data: []
});

heroUptimeGraphData.data.datasets.push({
label: 'Blue Team',
backgroundColor: '#2185d0',
data: []
});
heroUptimeGraphData.data.datasets.push({
label: 'Red Team',
backgroundColor: '#db2828',
data: []
});


for (let i in intervals) {
let interval = intervals[i];

Expand All @@ -2277,10 +2350,19 @@ function drawTeamStatGraphs() {
}
}

// parser v7 data
if (matchDetailMatch.teams[0].stats.uptimeHistogram) {
for (let i = 0; i <= 5; i++) {
heroUptimeGraphData.data.datasets[0].data.push(matchDetailMatch.teams[0].stats.uptimeHistogram[i]);
heroUptimeGraphData.data.datasets[1].data.push(matchDetailMatch.teams[1].stats.uptimeHistogram[i]);
}
}

teamOverallStatGraph.update();
teamfightStatGraph.update();
teamCCGraph.update();
timePerTierGraph.update();
heroUptimeGraph.update();
}

function updateTeamStats() {
Expand Down
8 changes: 8 additions & 0 deletions templates/match-detail-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,14 @@ <h3 class="ui red-team inverted small red header">RED Team</h3>
</div>
</div>
</div>
<div class="eight wide column">
<div class="ui inverted segment">
<div class="ui top attached label">Hero Uptime</div>
<div class="team-xp-graph-segment">
<canvas id="match-detail-hero-uptime"></canvas>
</div>
</div>
</div>
</div>
</div>
<div class="ui tab match-detail-wrapper" data-tab="match-detail-timeline" id="match-detail-timeline">
Expand Down

0 comments on commit 73266db

Please sign in to comment.