1import Highcharts from 'highcharts' 2 3import 'stats/highcharts-defaults' 4/* 5 * decaffeinate suggestions: 6 * DS102: Remove unnecessary code created because of implicit returns 7 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md 8 */ 9import decorate from 'stats/decorators/game' 10import { formatTooltip } from 'stats/helpers/charts' 11import { ord } from 'stats/helpers/string' 12import { secondsToHours } from 'stats/helpers/datetime' 13import { api, q, handleResponse } from 'stats/api' 14 15const data = document.getElementById('time-spent-chart').dataset 16 17const interpretation_team_statistics_url = 18 data.interpretationTeamStatisticsUrl 19const time_spent_statistics_url = data.timeSpentStatisticsUrl 20 21const { gameId } = data 22 23const gameRequest = api('games') 24 .from('games') 25 .select(q(['game_id', 'name', 'start', 'end'])) 26 .eq('game_id', gameId) 27 .single() 28 .then(handleResponse()) 29 30const gameStatisticsRequest = api('stats') 31 .from('game_statistics') 32 .select(q(['game_id', 'num_puzzles', 'num_teams'])) 33 .eq('game_id', gameId) 34 .single() 35 .then(handleResponse()) 36 37const seriesRequest = fetch(time_spent_statistics_url) 38 .then((response) => response.json()) 39 40const interpretationTeamStatisticsRequest = fetch(interpretation_team_statistics_url) 41 .then((response) => response.json()) 42 43const [game, stat, series, actions] = await Promise.all([gameRequest, gameStatisticsRequest, seriesRequest, interpretationTeamStatisticsRequest]) 44 45const tickInterval = decorate(game).getTickInterval() 46const team_count = stat.num_teams 47const categories = series[0].data.map((item) => item.name) 48 49Highcharts.chart('time-spent-chart', { 50 title: { 51 text: 'Doba luÅ¡tÄnà šifer' 52 }, 53 xAxis: { 54 categories, 55 labels: { 56 rotation: -45, 57 align: 'right' 58 }, 59 tickmarkPlacement: 'on' 60 }, 61 yAxis: [ 62 { 63 title: { 64 text: 'PoÅadà na Å¡ifÅe' 65 }, 66 min: 1, 67 max: team_count, 68 showFirstLabel: false, 69 reversed: false, 70 plotLines: [ 71 { 72 value: 0, 73 width: 1, 74 color: '#808080' 75 } 76 ] 77 }, 78 { 79 title: { 80 text: 'RozdÃl proti průmÄrnému Äasu luÅ¡tÄnÃ', 81 style: { 82 color: '#4572A7' 83 } 84 }, 85 tickInterval, 86 labels: { 87 formatter () { 88 return this.value / 3600 + 'h' 89 }, 90 style: { 91 color: '#4572A7' 92 } 93 }, 94 opposite: true 95 } 96 ], 97 tooltip: { 98 formatter () { 99 const action = actions[this.point.interpretation_id] 100 const { puzzle_rank, time_spent, best_time_spent, avg_time_spent } = action 101 const data = { 102 'PoÅadà na Å¡ifÅe': ord(puzzle_rank), 103 'Doba na Å¡ifÅe': secondsToHours(time_spent), 104 NejrychlejÅ¡Ã: secondsToHours(best_time_spent), 105 PrůmÄrný: secondsToHours(avg_time_spent) 106 } 107 return formatTooltip(this.x, data) 108 } 109 }, 110 series 111})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.