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">
$(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,

View File

@ -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,