var playerData = generatePlayerData(); var annualPlayerData = generateAnnualPlayerData(); var totalPlayerData = generateTotalPlayerData(); var chartSeasonProgression = AmCharts.makeChart("chartSeasonProgression", { "type": "serial", "theme": "light", "legend": { "useGraphSettings": true }, "dataProvider": playerData, "synchronizeGrid":true, "valueAxes": [{ "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "left" }, { "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "right" }], "graphs": [{ "id": "graphTotalLastYear", "valueAxis": "v2", "lineColor": "#0000FF", "balloonText": "[[title]]
[[value]] pts", "bullet": "square", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Last year", "valueField": "totalLastYear", "fillAlphas": 0 }, { "id": "graphTotalPlayerAverage", "valueAxis": "v3", "lineColor": "#000000", "balloonText": "[[title]]
[[value]] pts", "bullet": "triangleUp", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Player average", "valueField": "totalPlayerAverage", "fillAlphas": 0 }, { "id": "graphTotalThisYear", "valueAxis": "v1", "lineColor": "#008800", "balloonText": "[[title]]
[[value]] pts", "bullet": "round", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "This year", "valueField": "totalThisYear", "fillAlphas": 0 }], "chartScrollbar": { "graph":"graphTotalLastYear", "gridAlpha":0, "color":"#888888", "scrollbarHeight":55, "backgroundAlpha":0, "selectedBackgroundAlpha":0.1, "selectedBackgroundColor":"#888888", "graphFillAlpha":0, "autoGridCount":true, "selectedGraphFillAlpha":0, "graphLineAlpha":0.2, "graphLineColor":"#0000FF", "selectedGraphLineColor":"#0000FF", "selectedGraphLineAlpha":1 }, "chartCursor": { "cursorPosition": "mouse" }, "categoryField": "date", "categoryAxis": { "parseDates": true, "axisColor": "#DADADA", "minorGridEnabled": true }, "export": { "enabled": false, "position": "bottom-right" } }); chartSeasonProgression.addListener("dataUpdated", zoomChartSeasonProgression); var chartPointsPerGame = AmCharts.makeChart("chartPointsPerGame", { "type": "serial", "theme": "light", "legend": { "useGraphSettings": true }, "dataProvider": playerData, "synchronizeGrid":true, "valueAxes": [{ "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "left" }, { "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "right" }], "graphs": [{ "id": "graphLastYear", "valueAxis": "v2", "lineColor": "#0000FF", "balloonText": "[[title]]
[[value]] pts", "bullet": "square", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Last year", "valueField": "lastYear", "fillAlphas": 0 }, { "id": "graphPlayerAverage", "valueAxis": "v3", "lineColor": "#000000", "balloonText": "[[title]]
[[value]] pts", "bullet": "triangleUp", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Player average", "valueField": "playerAverage", "fillAlphas": 0 }, { "id": "graphThisYear", "valueAxis": "v1", "lineColor": "#008800", "balloonText": "[[title]]
[[value]] pts", "bullet": "round", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "This year", "valueField": "thisYear", "fillAlphas": 0 }], "chartScrollbar": { "graph":"graphLastYear", "gridAlpha":0, "color":"#888888", "scrollbarHeight":55, "backgroundAlpha":0, "selectedBackgroundAlpha":0.1, "selectedBackgroundColor":"#888888", "graphFillAlpha":0, "autoGridCount":true, "selectedGraphFillAlpha":0, "graphLineAlpha":0.2, "graphLineColor":"#0000FF", "selectedGraphLineColor":"#0000FF", "selectedGraphLineAlpha":1 }, "chartCursor": { "cursorPosition": "mouse" }, "categoryField": "date", "categoryAxis": { "parseDates": true, "axisColor": "#DADADA", "minorGridEnabled": true }, "export": { "enabled": false, "position": "bottom-right" } }); chartPointsPerGame.addListener("dataUpdated", zoomChartPointsPerGame); var chartYearlyProgression = AmCharts.makeChart("chartYearlyProgression", { "type": "serial", "theme": "light", "legend": { "useGraphSettings": true }, "dataProvider": annualPlayerData, "synchronizeGrid":true, "valueAxes": [{ "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "left" }, { "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "right" }], "graphs": [{ "id": "graphGoals", "valueAxis": "v2", "lineColor": "#008800", "balloonText": "[[category]]
[[value]] goals", "bullet": "square", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Goals", "valueField": "goals", "fillAlphas": 0 }, { "id": "graphAssists", "valueAxis": "v3", "lineColor": "#0000FF", "balloonText": "[[category]]
[[value]] assists", "bullet": "triangleUp", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Assists", "valueField": "assists", "fillAlphas": 0 }, { "id": "graphPoints", "valueAxis": "v1", "lineColor": "#000000", "balloonText": "[[category]]
[[value]] pts", "bullet": "round", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Points", "valueField": "points", "fillAlphas": 0 }], "chartScrollbar": { "graph":"graphPoints", "gridAlpha":0, "color":"#888888", "scrollbarHeight":55, "backgroundAlpha":0, "selectedBackgroundAlpha":0.1, "selectedBackgroundColor":"#888888", "graphFillAlpha":0, "autoGridCount":true, "selectedGraphFillAlpha":0, "graphLineAlpha":0.2, "graphLineColor":"#0000FF", "selectedGraphLineColor":"#0000FF", "selectedGraphLineAlpha":1 }, "chartCursor": { "cursorPosition": "mouse" }, "categoryField": "year", "categoryAxis": { "parseDates": false, "axisColor": "#DADADA", "minorGridEnabled": true }, "export": { "enabled": false, "position": "bottom-right" } }); chartYearlyProgression.addListener("dataUpdated", zoomChartYearlyProgression); var chartYearlyPointPerGameProgression = AmCharts.makeChart("chartYearlyPointPerGameProgression", { "type": "serial", "theme": "light", "legend": { "useGraphSettings": true }, "dataProvider": annualPlayerData, "synchronizeGrid":true, "valueAxes": [{ "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "left", "minimum": 0, "maximum": 2, "strictMinMax": true }, { "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "right", "minimum": 0, "maximum": 2, "strictMinMax": true }], "graphs": [{ "id": "graphPointsPerGame", "valueAxis": "v1", "lineColor": "#000000", "balloonText": "[[category]]
[[value]] pts", "bullet": "round", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Points per game", "valueField": "pointsPerGame", "fillAlphas": 0 }], "chartScrollbar": { "graph":"graphPointsPerGame", "gridAlpha":0, "color":"#888888", "scrollbarHeight":55, "backgroundAlpha":0, "selectedBackgroundAlpha":0.1, "selectedBackgroundColor":"#888888", "graphFillAlpha":0, "autoGridCount":true, "selectedGraphFillAlpha":0, "graphLineAlpha":0.2, "graphLineColor":"#0000FF", "selectedGraphLineColor":"#0000FF", "selectedGraphLineAlpha":1 }, "chartCursor": { "cursorPosition": "mouse" }, "categoryField": "year", "categoryAxis": { "parseDates": false, "axisColor": "#DADADA", "minorGridEnabled": true }, "export": { "enabled": false, "position": "bottom-right" } }); chartYearlyPointPerGameProgression.addListener("dataUpdated", zoomChartYearlyPointPerGameProgression); var chartTotalProduction = AmCharts.makeChart("chartTotalProduction", { "type": "serial", "theme": "light", "legend": { "useGraphSettings": true }, "dataProvider": totalPlayerData, "synchronizeGrid":true, "valueAxes": [{ "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "left" }, { "id":"v1", "axisColor": "#008800", "axisThickness": 2, "axisAlpha": 1, "position": "right" }], "graphs": [{ "id": "graphTotalGoals", "valueAxis": "v2", "lineColor": "#008800", "balloonText": "[[category]]
[[value]] goals", "bullet": "square", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Goals", "valueField": "goals", "fillAlphas": 0 }, { "id": "graphTotalAssists", "valueAxis": "v3", "lineColor": "#0000FF", "balloonText": "[[category]]
[[value]] assists", "bullet": "triangleUp", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Assists", "valueField": "assists", "fillAlphas": 0 }, { "id": "graphTotalPoints", "valueAxis": "v1", "lineColor": "#000000", "balloonText": "[[category]]
[[value]] pts", "bullet": "round", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Points", "valueField": "points", "fillAlphas": 0 }, { "id": "graphTotalCurrentTrend", "valueAxis": "v1", "lineColor": "#AAAAAA", "balloonText": "[[title]]
[[value]] pts", "bullet": "round", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Current trend", "valueField": "currentTrend", "fillAlphas": 0 }, { "id": "graphTotalAverageTrend", "valueAxis": "v1", "lineColor": "#FFA500", "balloonText": "[[title]]
[[value]] pts", "bullet": "round", "bulletBorderThickness": 1, "hideBulletsCount": 30, "title": "Average trend", "valueField": "averageTrend", "fillAlphas": 0 }], "chartScrollbar": { "graph":"graphTotalPoints", "gridAlpha":0, "color":"#888888", "scrollbarHeight":55, "backgroundAlpha":0, "selectedBackgroundAlpha":0.1, "selectedBackgroundColor":"#888888", "graphFillAlpha":0, "autoGridCount":true, "selectedGraphFillAlpha":0, "graphLineAlpha":0.2, "graphLineColor":"#0000FF", "selectedGraphLineColor":"#0000FF", "selectedGraphLineAlpha":1 }, "chartCursor": { "cursorPosition": "mouse" }, "categoryField": "date", "categoryAxis": { "parseDates": true, "axisColor": "#DADADA", "minorGridEnabled": true, "equalSpacing": true }, "export": { "enabled": false, "position": "bottom-right" } }); chartTotalProduction.addListener("dataUpdated", zoomChartTotalProduction); zoomChartSeasonProgression(); zoomChartPointsPerGame(); zoomChartYearlyProgression(); zoomChartYearlyPointPerGameProgression(); zoomChartTotalProduction(); function generatePlayerData() { var playerData = []; // If we're before August, use last year's first game var firstDate = new Date(2014, 9, 1, 0, 0, 0, 0); var thisYear = 0; var lastYear = 0; var playerAverage = 0; var totalThisYear = 0; var totalLastYear = 0; var totalPlayerAverage = 0;
Warning: mysqli::__construct(): (HY000/2002): Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (2) in /home/fantasyhockeypla/public_html/js/dataPlayer.php on line 489

Warning: mysqli::set_charset(): Couldn't fetch mysqli in /home/fantasyhockeypla/public_html/js/dataPlayer.php on line 490

Warning: mysqli::close(): Couldn't fetch mysqli in /home/fantasyhockeypla/public_html/js/dataPlayer.php on line 561
return playerData; } function generateAnnualPlayerData() { var annualPlayerData = []; var goals = 0; var assists = 0; var points = 0; var pointsPerGame = 0; var newYear = 0;
Warning: mysqli::__construct(): (HY000/2002): Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (2) in /home/fantasyhockeypla/public_html/js/dataPlayer.php on line 578

Warning: mysqli::set_charset(): Couldn't fetch mysqli in /home/fantasyhockeypla/public_html/js/dataPlayer.php on line 579

Warning: mysqli::close(): Couldn't fetch mysqli in /home/fantasyhockeypla/public_html/js/dataPlayer.php on line 636
return annualPlayerData; } function generateTotalPlayerData() { var totalPlayerData = []; var goals = 0; var assists = 0; var points = 0; var gameNumber = 0; var gameDate = '';
Warning: mysqli::__construct(): (HY000/2002): Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (2) in /home/fantasyhockeypla/public_html/js/dataPlayer.php on line 652

Warning: mysqli::set_charset(): Couldn't fetch mysqli in /home/fantasyhockeypla/public_html/js/dataPlayer.php on line 653

Warning: mysqli::close(): Couldn't fetch mysqli in /home/fantasyhockeypla/public_html/js/dataPlayer.php on line 691
var currentAveragePointsPerGame = totalPlayerData[totalPlayerData.length-1].points / (totalPlayerData.length - 1); var averagePointsPerGame = totalPlayerData[parseInt((totalPlayerData.length-1)/2)].points / parseInt((totalPlayerData.length-1)/2); var currentTrend = 0; var averageTrend = 0; for(var i = 0; i < totalPlayerData.length; i++) { totalPlayerData[i].currentTrend = currentTrend.toFixed(2); totalPlayerData[i].averageTrend = averageTrend.toFixed(2); currentTrend += currentAveragePointsPerGame; averageTrend += averagePointsPerGame; } return totalPlayerData; } function zoomChartSeasonProgression(){ /* By default, show up to today */ var nbGamesMinimum = 15; var firstGameOfYear = new Date(2014, 9, 1, 0, 0, 0, 0); var firstFifteenGames = new Date(2014, 9, 15, 0, 0, 0, 0); var today = new Date(); var lastIndex = datediff(firstGameOfYear, today) - 1; /* If today before the 15 first games, show the 15 first games */ if (today < firstFifteenGames) { lastIndex = nbGamesMinimum - 1; } /* If today is after the last game of the year, we use the last game */ if (lastIndex > chartSeasonProgression.dataProvider.length - 1) { lastIndex = chartSeasonProgression.dataProvider.length - 1; } chartSeasonProgression.zoomToIndexes(0, lastIndex); } function zoomChartPointsPerGame(){ /* By default, show last 25 days */ var nbGames = 25; var firstGameOfYear = new Date(2014, 9, 1, 0, 0, 0, 0); var lastGameOfYear = new Date(2015, 4, 30, 0, 0, 0, 0); var today = new Date(); var xNbGamesAgo = new Date(); var thisYear = new Date(); thisYear = thisYear.getFullYear(); // If we're in July or before, we check last year instead... if (today.getMonth() <= 6) { thisYear -= 1; } //If the year we're looking at isn't this year... if (2014 != thisYear) { today = lastGameOfYear; xNbGamesAgo = lastGameOfYear; } xNbGamesAgo.setDate(xNbGamesAgo.getDate() - nbGames); var firstIndex = 0; var lastIndex = nbGames - 1; /* If 25 games ago it's before the first game of the year, we start at the first game */ if (xNbGamesAgo < firstGameOfYear) { firstIndex = 0; } else { firstIndex = datediff(firstGameOfYear, xNbGamesAgo) - 1; } lastIndex = firstIndex + nbGames; /* If 25 days after 25 days ago is later than the last game of the year */ if (lastIndex > chartPointsPerGame.dataProvider.length - 1) { lastIndex = chartPointsPerGame.dataProvider.length - 1; /* Si on a plus que 25 parties dans l'année, on check les 25 dernières */ if (lastIndex >= 25) { firstIndex = lastIndex - 25; } } chartPointsPerGame.zoomToIndexes(firstIndex, lastIndex); } function zoomChartYearlyProgression(){ chartYearlyProgression.zoomToIndexes(0, chartYearlyProgression.dataProvider.length - 1); } function zoomChartYearlyPointPerGameProgression(){ chartYearlyPointPerGameProgression.zoomToIndexes(0, chartYearlyPointPerGameProgression.dataProvider.length - 1); } function zoomChartTotalProduction(){ chartTotalProduction.zoomToIndexes(0, chartTotalProduction.dataProvider.length - 1); }