Index: lams_central/web/includes/javascript/chart.js =================================================================== diff -u -r5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe -r2011f2215e55cae81f3ee2108daa5949ad0ee74c --- lams_central/web/includes/javascript/chart.js (.../chart.js) (revision 5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe) +++ lams_central/web/includes/javascript/chart.js (.../chart.js) (revision 2011f2215e55cae81f3ee2108daa5949ad0ee74c) @@ -152,6 +152,12 @@ // move the legend to the right of the chart legend.attr('transform', 'translate(' + (canvasWidth + CHART_MARGIN.right) + ',' + (CHART_MARGIN.top + 20) + ')'); } + + // functions to animate changed data + chartDiv.data('updateFunctions', { + 'y' : function(d) {return y(d.value);}, + 'height' : function(d) {return height - y(d.value);} + }); } /** Index: lams_learning/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe -r2011f2215e55cae81f3ee2108daa5949ad0ee74c --- lams_learning/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe) +++ lams_learning/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 2011f2215e55cae81f3ee2108daa5949ad0ee74c) @@ -184,4 +184,5 @@ label.kumalive.poll.missing.voters =Not voted label.kumalive.poll.results =Results label.kumalive.poll.votes.total =Total votes +button.kumalive.poll.chart.switch =Switch chart #======= End labels: Exported 151 labels for en AU ===== Index: lams_learning/web/css/kumalive.scss =================================================================== diff -u -r5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe -r2011f2215e55cae81f3ee2108daa5949ad0ee74c --- lams_learning/web/css/kumalive.scss (.../kumalive.scss) (revision 5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe) +++ lams_learning/web/css/kumalive.scss (.../kumalive.scss) (revision 2011f2215e55cae81f3ee2108daa5949ad0ee74c) @@ -107,6 +107,7 @@ #pollRunAnswerList .list-group-item.voted { border: $border-thin-primary; border-width: thick; + padding-right: 10px; } #pollRunAnswerList .list-group-item .badge { @@ -119,8 +120,8 @@ margin-top: 10px; } -#pollRunChartPie { - height: 320px; +#pollRunChartPie, #pollRunChartBar { + height: 340px; } #pollRun .pollVoters { Index: lams_learning/web/includes/javascript/kumalive.js =================================================================== diff -u -r5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe -r2011f2215e55cae81f3ee2108daa5949ad0ee74c --- lams_learning/web/includes/javascript/kumalive.js (.../kumalive.js) (revision 5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe) +++ lams_learning/web/includes/javascript/kumalive.js (.../kumalive.js) (revision 2011f2215e55cae81f3ee2108daa5949ad0ee74c) @@ -171,6 +171,7 @@ // hide all buttons and enable ones appropriate for the role $('#actionCell button').hide(); + $('#pollRunChartSwitch').click(switchPollChart); if (roleTeacher) { $('#raiseHandPromptButton').click(raiseHandPrompt); $('#downHandPromptButton').click(downHandPrompt); @@ -360,7 +361,7 @@ // update counters and charts if (poll.votes) { - $('#pollRunChart', pollRunDiv).show(); + $('#pollRunChart, #pollRunChartSwitch', pollRunDiv).show(); var chartData = [], voterCount = 0; @@ -386,10 +387,11 @@ // count all voters, no matter what they chose voterCount += count; }); - + // rewrite number of voters into percent var learnerCount = voterCount + poll.missingVotes, - chartDiv = $('#pollRunChartPie', pollRunDiv); + chartPieDiv = $('#pollRunChartPie', pollRunDiv), + chartBarDiv = $('#pollRunChartBar', pollRunDiv); $('#pollRunTotalVotes').text(voterCount + '/' + learnerCount + ' (' + Math.round(voterCount / learnerCount * 100) + '%)'); $.each(chartData, function() { @@ -401,18 +403,26 @@ 'value': Math.round(poll.missingVotes / learnerCount * 100) }); - if (chartDiv.is(':empty')) { - // draw a new chart + if (chartPieDiv.is(':empty')) { + // draw new charts drawChart('pie', 'pollRunChartPie', chartData, false); + drawChart('bar', 'pollRunChartBar', chartData, false); + chartBarDiv.hide(); } else { - // update chart data using functions set in chart.js - var updateFunctions = chartDiv.data('updateFunctions'); - d3.select(chartDiv[0]).selectAll('path').data(updateFunctions.pie(chartData)) + // update pie chart data using functions stored in chart.js + var updateFunctions = chartPieDiv.data('updateFunctions'); + d3.select(chartPieDiv[0]).selectAll('path').data(updateFunctions.pie(chartData)) .transition().duration(750).attrTween("d", updateFunctions.arcTween); // update legend - chartDiv.find('text').each(function(answerIndex, legendItem){ + chartPieDiv.find('text').each(function(answerIndex, legendItem){ $(legendItem).text(chartData[answerIndex].name + ' (' + chartData[answerIndex].value + '%)'); }); + + // update bar chart + updateFunctions = chartBarDiv.data('updateFunctions'); + d3.select(chartBarDiv[0]).selectAll('.bar').data(chartData).transition().duration(750) + .attr("y", updateFunctions.y) + .attr("height", updateFunctions.height); } } @@ -1003,6 +1013,10 @@ $('#pollRunReleaseVotesButton, #pollRunReleaseVotersButton').hide(); } +function switchPollChart() { + $('#pollRunChartPie, #pollRunChartBar').toggle(); +} + /** * Prevent learners from voting */ Index: lams_learning/web/kumalive/kumalive.jsp =================================================================== diff -u -r5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe -r2011f2215e55cae81f3ee2108daa5949ad0ee74c --- lams_learning/web/kumalive/kumalive.jsp (.../kumalive.jsp) (revision 5b76fc85b49c6dc9dbedfac8b235e9e3d56ef8fe) +++ lams_learning/web/kumalive/kumalive.jsp (.../kumalive.jsp) (revision 2011f2215e55cae81f3ee2108daa5949ad0ee74c) @@ -171,6 +171,9 @@ +