[IMP] added pie chart for simple questions and table condensed class to tables, and set limit of 10 records for pagination
bzr revid: dizzy.zala@gmail.com-20140324100257-fz8id6eula73x4yx
This commit is contained in:
parent
2ffa234d3d
commit
6a0fa7c3ff
|
@ -69,8 +69,16 @@ $(document).ready(function () {
|
|||
.showValues(true);
|
||||
}
|
||||
|
||||
//initialize Pie Chart
|
||||
function init_pie_chart(){
|
||||
return nv.models.pieChart()
|
||||
.x(function(d) { return d.text; })
|
||||
.y(function(d) { return d.count; })
|
||||
.showLabels(true);
|
||||
}
|
||||
|
||||
//load chart to svg element chart:initialized chart, response:AJAX response, quistion_id:if of survey question, tick_limit:text length limit
|
||||
function load_chart(chart, response, question_id, tick_limit){
|
||||
function load_chart(chart, response, question_id, tick_limit, graph_type){
|
||||
// Custom Tick fuction for replacing long text with '...'
|
||||
var customtick_function = function(d){
|
||||
if(! this || d.length <= tick_limit){
|
||||
|
@ -80,14 +88,20 @@ $(document).ready(function () {
|
|||
return d.slice(0,tick_limit)+'...';
|
||||
}
|
||||
};
|
||||
chart.xAxis
|
||||
.tickFormat(customtick_function);
|
||||
chart.yAxis
|
||||
.tickFormat(d3.format('d'));
|
||||
|
||||
d3.select('#graph_question_' + question_id + ' svg')
|
||||
.datum(response)
|
||||
.transition().duration(500).call(chart);
|
||||
if (graph_type == 'pie'){
|
||||
d3.select('#graph_question_' + question_id + ' svg')
|
||||
.datum(response[0].values)
|
||||
.transition().duration(500).call(chart);
|
||||
}
|
||||
else{
|
||||
chart.xAxis
|
||||
.tickFormat(customtick_function);
|
||||
chart.yAxis
|
||||
.tickFormat(d3.format('d'));
|
||||
d3.select('#graph_question_' + question_id + ' svg')
|
||||
.datum(response)
|
||||
.transition().duration(500).call(chart);
|
||||
}
|
||||
nv.utils.windowResize(chart.update);
|
||||
return chart;
|
||||
}
|
||||
|
@ -116,6 +130,12 @@ $(document).ready(function () {
|
|||
return load_chart(chart,response,question_id,35);
|
||||
});
|
||||
}
|
||||
else if(graph_type == 'pie'){
|
||||
nv.addGraph(function() {
|
||||
var chart = init_pie_chart();
|
||||
return load_chart(chart,response,question_id,25,'pie');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<!-- Result for free_text,textbox and datetime -->
|
||||
<template id="result_text" name="Text Result">
|
||||
<t t-if="input_summary['answered'] != 0">
|
||||
<table class="table table-hover" t-att-id="'table_question_'+str(question.id)">
|
||||
<table class="table table-hover table-condensed" t-att-id="'table_question_'+str(question.id)">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
|
@ -113,11 +113,16 @@
|
|||
<div>
|
||||
<!-- Tabs -->
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active">
|
||||
<li class="active" t-if="question.type != 'simple_choice'">
|
||||
<a t-att-href="'#graph_question_'+str(question.id)" data-toggle="tab">
|
||||
<i class="fa fa-bar-chart-o"></i> Graph
|
||||
</a>
|
||||
</li>
|
||||
<li class="active" t-if="question.type == 'simple_choice'">
|
||||
<a t-att-href="'#graph_question_'+str(question.id)" data-toggle="tab">
|
||||
<i class="fa fa-dot-circle-o"></i> Pie Chart
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a t-att-href="'#data_question_'+str(question.id)" data-toggle="tab">
|
||||
<i class="fa fa-list-alt"></i> Data
|
||||
|
@ -125,12 +130,16 @@
|
|||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active survey_graph" t-att-id="'graph_question_'+str(question.id)" t-att-data-question_id="question.id" data-graph_type="bar" t-att-data-current_filters="current_filters">
|
||||
<div class="tab-pane active survey_graph" t-if="question.type != 'simple_choice'" t-att-id="'graph_question_'+str(question.id)" t-att-data-question_id="question.id" data-graph_type="bar" t-att-data-current_filters="current_filters">
|
||||
<!-- svg element for drawing bar chart -->
|
||||
<svg style="height:20em"></svg>
|
||||
</div>
|
||||
<div class="tab-pane active survey_graph" t-if="question.type == 'simple_choice'" t-att-id="'graph_question_'+str(question.id)" t-att-data-question_id="question.id" data-graph_type="pie" t-att-data-current_filters="current_filters">
|
||||
<!-- svg element for drawing pie chart -->
|
||||
<svg style="height:20em"></svg>
|
||||
</div>
|
||||
<div class="tab-pane" t-att-id="'data_question_'+str(question.id)">
|
||||
<table class="table table-hover">
|
||||
<table class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Answer Choices</th>
|
||||
|
@ -179,7 +188,7 @@
|
|||
<svg style="height:20em"></svg>
|
||||
</div>
|
||||
<div class="tab-pane" t-att-id="'data_question_'+str(question.id)">
|
||||
<table class="table table-hover text-right">
|
||||
<table class="table table-hover table-condensed text-right">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
|
@ -229,7 +238,7 @@
|
|||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active with-3d-shadow with-transitions" t-att-id="'most_common_'+str(question.id)">
|
||||
<table class="table table-hover">
|
||||
<table class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User Responce</th>
|
||||
|
@ -249,7 +258,7 @@
|
|||
</table>
|
||||
</div>
|
||||
<div class="tab-pane" t-att-id="'data_question_'+str(question.id)">
|
||||
<table class="table table-hover" t-att-id="'table_question_'+str(question.id)">
|
||||
<table class="table table-hover table-condensed" t-att-id="'table_question_'+str(question.id)">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
|
@ -287,7 +296,7 @@
|
|||
</template>
|
||||
<!-- Pagination Element -->
|
||||
<template id="pagination" name="Survey Result">
|
||||
<t t-set="record_limit" t-value="5"/><!-- Change This record_limit to change number of record per page-->
|
||||
<t t-set="record_limit" t-value="10"/><!-- Change This record_limit to change number of record per page-->
|
||||
<ul t-att-id="'pagination_%d' % question.id" class="pagination" t-att-data-question_id="question.id" t-att-data-record_limit="record_limit">
|
||||
<t t-if="len(text_result) > record_limit">
|
||||
<li t-foreach="page_range(len(text_result), record_limit)" t-as="num">
|
||||
|
|
Loading…
Reference in New Issue