function drawAnnualProgressionCharts() { jQuery('.chart-progression').each(function(index, container) { var data = new google.visualization.DataTable(); data.addColumn('date', 'Year'); data.addColumn('number', 'Mark'); //data.addColumn('timeofday', markText); data.addColumn({'type': 'string', 'role': 'tooltip', 'p': { 'html': true } }); data.addColumn({'type': 'string', 'role':'style'}); disciplineGroup = jQuery(container).attr('data-discipline-group'); var dataPHP = jQuery.parseJSON(jQuery(container).attr('data-json')); rows = new Array(); jQuery.each(dataPHP, function(index, value) { dateSplitted = value.date.split('-'); pointColor = (value.windy)? '#ff9933' : '#de142c'; rows[index] = new Array(new Date(dateSplitted[0], dateSplitted[1]-1, dateSplitted[2]), parseFloat(value.result), createCustomHTMLContent(dateSplitted[2]+'.'+dateSplitted[1]+'.'+dateSplitted[0], value.location, value.resultFormatted), pointColor); }); vAxisTicks = calculateTicksFromResults(rows, disciplineGroup); vAxisDirection = getVAxisDirection(disciplineGroup); data.addRows(rows); var options = { width: jQuery('table.rankings').eq(0).width(), // Must set width because chart loaded in hidden tabs pointSize: 10, hAxis: { title: 'Year', format: 'yyyy', showTextEvery: 5 }, vAxis: { title: 'Mark', ticks: vAxisTicks, direction: vAxisDirection }, tooltip: { isHtml: true } }; // Show the chart before drawing it, otherwise width and height will be wrong var chart = new google.visualization.LineChart(container); google.visualization.events.addListener(chart, 'ready', function () { }); chart.draw(data, options); }); } function drawYearlyProgressionCharts() { jQuery('.chart-yearly-progression').each(function(index, container) { var data = new google.visualization.DataTable(); data.addColumn('date', 'Month'); data.addColumn('number', 'Mark'); data.addColumn({ 'type': 'string', 'role': 'tooltip', 'p': { 'html': true } }); data.addColumn({'type': 'string', 'role':'style'}); disciplineGroup = jQuery(container).attr('data-discipline-group'); var dataPHP = jQuery.parseJSON(jQuery(container).attr('data-json')); rows = new Array(); jQuery.each(dataPHP, function(index, value) { dateSplitted = value.date.split('-'); pointColor = (value.windy)? '#ff9933' : '#de142c'; rows[index] = new Array(new Date(dateSplitted[0], dateSplitted[1]-1, dateSplitted[2]), parseFloat(value.result), createCustomHTMLContent(dateSplitted[2]+'.'+dateSplitted[1]+'.'+dateSplitted[0], value.location, value.resultFormatted), pointColor); }); vAxisTicks = calculateTicksFromResults(rows, disciplineGroup); vAxisDirection = getVAxisDirection(disciplineGroup); data.addRows(rows); var options = { pointSize: 10, hAxis: { title: 'Month', format: 'M', showTextEvery: 2 }, vAxis: { title: 'Mark', ticks: vAxisTicks, direction: vAxisDirection }, tooltip: { isHtml: true } }; // Show the chart before drawing it, otherwise width and height will be wrong //container.style.display = 'block'; var chart = new google.visualization.LineChart(container); google.visualization.events.addListener(chart, 'ready', function () { //jQuery(container).parent().hide(); //style.display = 'none'; }); chart.draw(data, options); }); } function drawRecordEvolutionChart() { jQuery('.chart-record-evolution').each(function(index, container) { var data = new google.visualization.DataTable(); data.addColumn('date', 'Year'); data.addColumn('number', 'Mark'); //data.addColumn('timeofday', markText); data.addColumn({'type': 'string', 'role': 'tooltip', 'p': { 'html': true } }); data.addColumn({'type': 'string', 'role':'style'}); pointColor = '#de142c'; var dataPHP = jQuery.parseJSON(jQuery(container).attr('data-json')); rows = new Array(); jQuery.each(dataPHP, function(index, value) { dateSplitted = value.date.split('-'); rows[index] = new Array(new Date(dateSplitted[0], dateSplitted[1]-1, dateSplitted[2]), parseFloat(value.result), createCustomHTMLContent(dateSplitted[2]+'.'+dateSplitted[1]+'.'+dateSplitted[0], value.athlete, value.resultFormatted), pointColor); }); //vAxisTicks = calculateTicksFromResults(rows, disciplineGroup); data.addRows(rows); var options = { width: jQuery('table.rankings').eq(0).width(), // Must set width because chart loaded in hidden tabs pointSize: 10, hAxis: { title: 'Year', format: 'yyyy' }, vAxis: { title: 'Mark' }, tooltip: { isHtml: true } }; // Show the chart before drawing it, otherwise width and height will be wrong var chart = new google.visualization.LineChart(container); google.visualization.events.addListener(chart, 'ready', function () { }); chart.draw(data, options); }); } function drawHeadToHeadDonut() { nbWins = parseInt(jQuery('#head-to-head').attr('data-wins')); nbLosses = parseInt(jQuery('#head-to-head').attr('data-losses')); percentageWins = (100 / (nbWins+nbLosses)) * nbWins; var doughnutData = [ {value:percentageWins,color:"#DD142C"}, {value:100-percentageWins,color:"#c2c2c2"} ]; $("#head-to-head").doughnutit({ dnData: doughnutData, dnSize: 150, dnInnerCutout: 70, dnAnimation: true, dnAnimationSteps: 60, dnAnimationEasing: 'linear', dnStroke: false, dnShowText: true, dnFontSize: '50px', dnFontColor: "#ccc", dnText: 'VS', dnStartAngle: 0, dnCounterClockwise: false, });// End Doughnut } function loadDisciplinesPerSeason(season) { firstSelected = false; if(season == 'indoor') { jQuery.each(jQuery('#results_per_year_discipline option'), function(key, val){ if(jQuery(this).text().indexOf('indoor') >-1) { if(!firstSelected) {jQuery(this).prop('selected', true); firstSelected = true;} jQuery(this).show(); } else { jQuery(this).hide(); } }); } else { jQuery.each(jQuery('#results_per_year_discipline option'), function(key, val){ if(jQuery(this).text().indexOf('indoor') == -1) { if(!firstSelected) {jQuery(this).prop('selected', true); firstSelected = true;} jQuery(this).show(); } else { jQuery(this).hide(); } }); } // Select first one //jQuery('#results_per_year_discipline option').not(':hidden').eq(0).prop('selected', true); } /*jQuery('.block-link').click(function(e) { e.preventDefault(); // Get index in page index = jQuery('.block-link').index(this); jQuery('.chart-container').eq(index).toggle(); return false; });*/ function createCustomHTMLContent(date, location, mark) { return '