From: CMDR furrycat Date: Mon, 8 Feb 2016 15:23:47 +0000 (-0500) Subject: Show time raced by competitors. X-Git-Url: http://git.furryclan.net/?a=commitdiff_plain;h=583cab8e390a4c4a30877121529eb90ecd5bc681;p=furrycat%2Frace-o-matic.git Show time raced by competitors. --- diff --git a/lib/race.php b/lib/race.php index 6435544..33a7bc3 100644 --- a/lib/race.php +++ b/lib/race.php @@ -530,6 +530,7 @@ echo "
\n"; echo "
\n"; echo "
\n"; + echo "
\n"; echo "
\n"; /* Sort options. */ @@ -724,10 +725,13 @@ $hulls = array(); $lap_counts = array(); $lap_distances = array(); + $time_raced = array(); foreach ($filtered_entries as $entry) { $ship = $entry->getShip(); $cmdr_name = $ship->getCompetitor()->getCmdrName(); $hull_name = $ship->getHull()->getName(); + if (! array_key_exists($cmdr_name, $time_raced)) $time_raced[$cmdr_name] = 0; + $time_raced[$cmdr_name] += $entry->getRacedTime(); $lap_count = $entry->getCompleteLaps(); $lap_count = sprintf("%d lap%s", $lap_count, ($lap_count == 1) ? "" : "s"); $lap_distance = format_distance($entry->getLapDistance()) . "Ly"; @@ -818,11 +822,18 @@ $laps["fastest_laps"]["x"][] = "Lap " . $row["lap_number"]; $laps["fastest_laps"]["y"][] = (int) $row["n"]; } + arsort($time_raced); + foreach ($time_raced as $cmdr_name => $time) { + $raced_times["raced_times"]["x"][] = $cmdr_name; + $raced_times["raced_times"]["y"][] = "2000-01-01 " . format_time($time); + } + /* Time raced. */ echo "\n"; } echo "
\n"; diff --git a/race.js b/race.js index 87128c8..832c5dc 100644 --- a/race.js +++ b/race.js @@ -168,6 +168,11 @@ function loaded() { if (canvas && laps) Plotly.plot(canvas, laps, { title: 'Fastest individual laps', }); + canvas = document.getElementById('plot_raced_times'); + if (canvas && raced_times) Plotly.plot(canvas, raced_times, { + title: 'Time raced', + yaxis: { title: 'Time', tickformat: '%H:%M:%S' } + }); } document.onload = loaded();