}
//Load character data
$characters = getCharacterData();
//Season dropdown
$season_list = getSeasonList();
end($season_list);
$current_season = key($season_list);
reset($season_list);
//Data for the linechart display needs to be character_id => array of seasonid=>sum
$stats = array();
//Init main structure
foreach ($characters as $id => $v) {
    $stats[$id] = array();
}
foreach ($season_list as $id => $stuff) {
    $data = getDataForSingleSeason($first_rank, $last_rank, $id == $current_season ? NULL : $id, $characters, "sortBySum");
    //returns id,sum,rank_avg
    foreach ($data as $row) {
        $stats[$row["id"]][$id] = $row["sum"];
    }
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Awesomecharts | Stats over the seasons</title>
<link rel="stylesheet" type="text/css" href="main.css">
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css">
    $axis_title = "Average win ratio %";
}
//Load character data
$characters = getCharacterData();
//Season dropdown
$season_list = getSeasonList();
end($season_list);
$current_season = key($season_list);
reset($season_list);
// Set season id to correct number
if ($season_id === NULL || $season_id > $current_season || $season_id < 8) {
    $season_id = $current_season;
}
//Load data for display (season-id === NULL > current)
//data structure ..=>id,sum,rank_avg
$data = getDataForSingleSeason($first_rank, $last_rank, $season_id == $current_season ? NULL : $season_id, $characters, $sortFunction);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Awesomecharts | Stats for season</title>
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css">
  
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
  
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.5/js/jquery.dataTables.js"></script>