Add chart for int responses
This commit is contained in:
parent
2c66c58d4f
commit
41df85c33b
@ -17,7 +17,7 @@
|
|||||||
proposal_idx[proposal.id] = new String(data.labels.length - 1);
|
proposal_idx[proposal.id] = new String(data.labels.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
req_responses = refreshResponses();
|
req_responses = question.getResponses();
|
||||||
req_responses.then((responses) => {
|
req_responses.then((responses) => {
|
||||||
for (const res of responses) {
|
for (const res of responses) {
|
||||||
data.datasets[0].values[proposal_idx[res.value]] += 1;
|
data.datasets[0].values[proposal_idx[res.value]] += 1;
|
||||||
@ -27,9 +27,27 @@
|
|||||||
|
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
let req_proposals = refreshProposals();
|
let req_proposals = null;
|
||||||
let req_responses = null;
|
let req_responses = null;
|
||||||
|
|
||||||
|
if (question.kind == "int") {
|
||||||
|
req_responses = question.getResponses();
|
||||||
|
req_responses.then((responses) => {
|
||||||
|
const proposal_idx = { };
|
||||||
|
for (const res of responses) {
|
||||||
|
if (proposal_idx[res.value]) {
|
||||||
|
data.datasets[0].values[proposal_idx[res.value]] += 1;
|
||||||
|
} else {
|
||||||
|
data.labels.push(res.value);
|
||||||
|
data.datasets[0].values.push(1);
|
||||||
|
proposal_idx[res.value] = new String(data.labels.length - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
req_proposals = refreshProposals();
|
||||||
|
}
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
labels: [],
|
labels: [],
|
||||||
datasets: [
|
datasets: [
|
||||||
|
@ -108,7 +108,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if question.kind == "ucq" || question.kind == "mcq"}
|
{#if question.kind == "ucq" || question.kind == "mcq" || question.kind == "int"}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-sm float-end mx-1"
|
class="btn btn-sm float-end mx-1"
|
||||||
|
Reference in New Issue
Block a user