From 57722777921278f2f5241f904dc1cadc3e000bf3 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ <olivier@olivierperez.fr> Date: Tue, 23 Jun 2015 21:54:39 +0200 Subject: [PATCH] Don't skip the last column on charts --- tpl/part/vote_table_classic.tpl | 18 +++++++++++------- tpl/part/vote_table_date.tpl | 21 ++++++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/tpl/part/vote_table_classic.tpl b/tpl/part/vote_table_classic.tpl index 725c4c98..20fe8858 100644 --- a/tpl/part/vote_table_classic.tpl +++ b/tpl/part/vote_table_classic.tpl @@ -192,19 +192,23 @@ <script type="text/javascript"> $(document).ready(function () { $('#showChart').on('click', function() { - $('#showChart').after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>"); - $('#showChart').remove(); + $('#showChart') + .after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>") + .remove(); var resIfneedbe = []; var resYes = []; - $('#addition').find('td').each(function (colIndex) { - if($(this).find('.inb-count').text()!='' && $(this).find('.inb-count').text()!=undefined) { + $('#addition').find('td').each(function () { + var inbCountText = $(this).find('.inb-count').text(); + if(inbCountText != '' && inbCountText != undefined) { resIfneedbe.push($(this).find('.inb-count').html()) } else { resIfneedbe.push(0); } - if($(this).find('.yes-count').text()!='' && $(this).find('.yes-count').text()!=undefined) { + + var yesCountText = $(this).find('.yes-count').text(); + if(yesCountText != '' && yesCountText != undefined) { resYes.push($(this).find('.yes-count').html()) } else { resYes.push(0); @@ -216,8 +220,8 @@ {/foreach} ]; - resIfneedbe.shift(); resIfneedbe.pop(); - resYes.shift(); resYes.pop(); + resIfneedbe.shift(); + resYes.shift(); var barChartData = { labels : cols, diff --git a/tpl/part/vote_table_date.tpl b/tpl/part/vote_table_date.tpl index cf3f3758..7bd6781a 100644 --- a/tpl/part/vote_table_date.tpl +++ b/tpl/part/vote_table_date.tpl @@ -247,20 +247,23 @@ <script type="text/javascript"> $(document).ready(function () { $('#showChart').on('click', function() { - $('#showChart').after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>"); - $('#showChart').remove(); + $('#showChart') + .after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>") + .remove(); var resIfneedbe = []; var resYes = []; - $('#addition').find('td').each(function (colIndex) { - if($(this).find('.inb-count').text()!='') { - resIfneedbe.push($(this).find('.inb-count').text()) + $('#addition').find('td').each(function () { + var inbCountText = $(this).find('.inb-count').text(); + if(inbCountText != '' && inbCountText != undefined) { + resIfneedbe.push(inbCountText) } else { resIfneedbe.push(0); } - if($(this).find('.yes-count').text()!='') { - resYes.push($(this).find('.yes-count').text()) + var yesCountText = $(this).find('.yes-count').text(); + if(yesCountText != '' && yesCountText != undefined) { + resYes.push(yesCountText) } else { resYes.push(0); } @@ -273,8 +276,8 @@ {/foreach} ]; - resIfneedbe.shift(); resIfneedbe.pop(); - resYes.shift(); resYes.pop(); + resIfneedbe.shift(); + resYes.shift(); var barChartData = { labels : cols, -- GitLab