Don't skip the last column on charts

This commit is contained in:
Olivier PEREZ 2015-06-23 21:54:39 +02:00
parent f50d504932
commit 5772277792
2 changed files with 23 additions and 16 deletions

View File

@ -192,19 +192,23 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$('#showChart').on('click', function() { $('#showChart').on('click', function() {
$('#showChart').after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>"); $('#showChart')
$('#showChart').remove(); .after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>")
.remove();
var resIfneedbe = []; var resIfneedbe = [];
var resYes = []; var resYes = [];
$('#addition').find('td').each(function (colIndex) { $('#addition').find('td').each(function () {
if($(this).find('.inb-count').text()!='' && $(this).find('.inb-count').text()!=undefined) { var inbCountText = $(this).find('.inb-count').text();
if(inbCountText != '' && inbCountText != undefined) {
resIfneedbe.push($(this).find('.inb-count').html()) resIfneedbe.push($(this).find('.inb-count').html())
} else { } else {
resIfneedbe.push(0); 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()) resYes.push($(this).find('.yes-count').html())
} else { } else {
resYes.push(0); resYes.push(0);
@ -216,8 +220,8 @@
{/foreach} {/foreach}
]; ];
resIfneedbe.shift(); resIfneedbe.pop(); resIfneedbe.shift();
resYes.shift(); resYes.pop(); resYes.shift();
var barChartData = { var barChartData = {
labels : cols, labels : cols,

View File

@ -247,20 +247,23 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$('#showChart').on('click', function() { $('#showChart').on('click', function() {
$('#showChart').after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>"); $('#showChart')
$('#showChart').remove(); .after("<h3>{__('Poll results', 'Chart')}</h3><canvas id=\"Chart\"></canvas>")
.remove();
var resIfneedbe = []; var resIfneedbe = [];
var resYes = []; var resYes = [];
$('#addition').find('td').each(function (colIndex) { $('#addition').find('td').each(function () {
if($(this).find('.inb-count').text()!='') { var inbCountText = $(this).find('.inb-count').text();
resIfneedbe.push($(this).find('.inb-count').text()) if(inbCountText != '' && inbCountText != undefined) {
resIfneedbe.push(inbCountText)
} else { } else {
resIfneedbe.push(0); resIfneedbe.push(0);
} }
if($(this).find('.yes-count').text()!='') { var yesCountText = $(this).find('.yes-count').text();
resYes.push($(this).find('.yes-count').text()) if(yesCountText != '' && yesCountText != undefined) {
resYes.push(yesCountText)
} else { } else {
resYes.push(0); resYes.push(0);
} }
@ -273,8 +276,8 @@
{/foreach} {/foreach}
]; ];
resIfneedbe.shift(); resIfneedbe.pop(); resIfneedbe.shift();
resYes.shift(); resYes.pop(); resYes.shift();
var barChartData = { var barChartData = {
labels : cols, labels : cols,