mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
Ajout formatage données
This commit is contained in:
parent
2261bd2406
commit
c36a3b064c
89
package-lock.json
generated
89
package-lock.json
generated
@ -2512,6 +2512,32 @@
|
||||
"integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
|
||||
"dev": true
|
||||
},
|
||||
"chart.js": {
|
||||
"version": "2.9.3",
|
||||
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-2.9.3.tgz",
|
||||
"integrity": "sha512-+2jlOobSk52c1VU6fzkh3UwqHMdSlgH1xFv9FKMqHiNCpXsGPQa/+81AFa+i3jZ253Mq9aAycPwDjnn1XbRNNw==",
|
||||
"requires": {
|
||||
"chartjs-color": "^2.1.0",
|
||||
"moment": "^2.10.2"
|
||||
}
|
||||
},
|
||||
"chartjs-color": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/chartjs-color/-/chartjs-color-2.4.1.tgz",
|
||||
"integrity": "sha512-haqOg1+Yebys/Ts/9bLo/BqUcONQOdr/hoEr2LLTRl6C5LXctUdHxsCYfvQVg5JIxITrfCNUDr4ntqmQk9+/0w==",
|
||||
"requires": {
|
||||
"chartjs-color-string": "^0.6.0",
|
||||
"color-convert": "^1.9.3"
|
||||
}
|
||||
},
|
||||
"chartjs-color-string": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/chartjs-color-string/-/chartjs-color-string-0.6.0.tgz",
|
||||
"integrity": "sha512-TIB5OKn1hPJvO7JcteW4WY/63v6KwEdt6udfnDE9iCAZgy+V4SrbSxoIbTw/xkUIapjEI4ExGtD0+6D3KyFd7A==",
|
||||
"requires": {
|
||||
"color-name": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"chokidar": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.0.2.tgz",
|
||||
@ -2739,7 +2765,6 @@
|
||||
"version": "1.9.3",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
||||
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-name": "1.1.3"
|
||||
}
|
||||
@ -2747,8 +2772,7 @@
|
||||
"color-name": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
|
||||
"dev": true
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
|
||||
},
|
||||
"colors": {
|
||||
"version": "1.1.2",
|
||||
@ -5659,8 +5683,7 @@
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@ -5703,8 +5726,7 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
@ -5715,8 +5737,7 @@
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -5833,8 +5854,7 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@ -5846,7 +5866,6 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -5876,7 +5895,6 @@
|
||||
"version": "2.3.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.0"
|
||||
@ -5895,7 +5913,6 @@
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@ -5989,7 +6006,6 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -6075,8 +6091,7 @@
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
@ -6112,7 +6127,6 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@ -6132,7 +6146,6 @@
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
@ -6176,14 +6189,12 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -6913,6 +6924,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.24.0",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
|
||||
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
|
||||
},
|
||||
"move-concurrently": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
|
||||
@ -11265,8 +11281,7 @@
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@ -11309,8 +11324,7 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
@ -11321,8 +11335,7 @@
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -11439,8 +11452,7 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@ -11452,7 +11464,6 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -11482,7 +11493,6 @@
|
||||
"version": "2.3.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.0"
|
||||
@ -11501,7 +11511,6 @@
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@ -11595,7 +11604,6 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -11681,8 +11689,7 @@
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
@ -11718,7 +11725,6 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@ -11738,7 +11744,6 @@
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
@ -11782,14 +11787,12 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -10,65 +10,150 @@ export class PollGraphicComponent implements OnInit {
|
||||
isColorblind: boolean;
|
||||
lineChart: Chart;
|
||||
pollData: any;
|
||||
|
||||
yesList: number[] = [];
|
||||
maybeList: number[] = [];
|
||||
noList: number[] = [];
|
||||
nbPoll: number = 0;
|
||||
dateList: string[] = [];
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {
|
||||
var toto = {
|
||||
step: 0,
|
||||
stepMax: 3,
|
||||
pollType: "special dates",
|
||||
title: "",
|
||||
description: "",
|
||||
myName: "",
|
||||
visibility: "link_only",
|
||||
// date specific poll
|
||||
allowSeveralHours: "true",
|
||||
dateLgfgfgfgist: ["jeudi", "vendredi", "samedi"], // sets of days as strings
|
||||
timeList: ["08:00", "08:30", "09:00"], // ranges of time expressed as strings
|
||||
answers: [
|
||||
{
|
||||
id: 0,
|
||||
text: "no"
|
||||
},
|
||||
|
||||
//const data = this.formatDataAnswers();
|
||||
{
|
||||
id: 1,
|
||||
text: "yes"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
text: "maybe"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
text: "maybe"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
text: "maybe"
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
text: "maybe"
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
text: "maybe"
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
text: "maybe"
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
text: "maybe"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.formatDataAnswers(toto);
|
||||
|
||||
this.isColorblind = false;
|
||||
this.pollData = new Chart(document.getElementById("graph"), {
|
||||
type: 'horizontalBar',
|
||||
type: "horizontalBar",
|
||||
data: {
|
||||
labels: ["Je 17 août 8h00", "Je 17 août 8h00", "Je 17 août 8h00"],
|
||||
datasets: [{
|
||||
type: "horizontalBar",
|
||||
stack: "Yes",
|
||||
backgroundColor: "#429a00",
|
||||
data: [30, 31, 32, 33, 34, 35, 36],
|
||||
}, {
|
||||
type: "horizontalBar",
|
||||
stack: "Yes",
|
||||
backgroundColor: "#f5a623",
|
||||
data: [15, 16, 17, 18, 19, 20, 21],
|
||||
}, {
|
||||
type: "horizontalBar",
|
||||
stack: "No",
|
||||
backgroundColor: "#cd0000",
|
||||
data: [20, 21, 22, 23, 24, 25, 26],
|
||||
}]
|
||||
labels: ["jeudi"],
|
||||
datasets: [
|
||||
{
|
||||
type: "horizontalBar",
|
||||
stack: "Yes",
|
||||
backgroundColor: "#429a00",
|
||||
data: this.yesList
|
||||
},
|
||||
{
|
||||
type: "horizontalBar",
|
||||
stack: "Yes",
|
||||
backgroundColor: "#f5a623",
|
||||
data: this.maybeList
|
||||
},
|
||||
{
|
||||
type: "horizontalBar",
|
||||
stack: "No",
|
||||
backgroundColor: "#cd0000",
|
||||
data: this.noList
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
legend:{display:false},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
gridLines: {drawBorder:false, display:false},
|
||||
display:false,
|
||||
stacked: true,
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
maxRotation: 0,
|
||||
minRotation: 0
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
gridLines: {drawBorder: true, display: false},
|
||||
display:true,
|
||||
stacked: true,
|
||||
}]
|
||||
},
|
||||
legend: { display: false },
|
||||
scales: {
|
||||
xAxes: [
|
||||
{
|
||||
gridLines: { drawBorder: false, display: false },
|
||||
display: false,
|
||||
stacked: true,
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
maxRotation: 0,
|
||||
minRotation: 0
|
||||
}
|
||||
}
|
||||
],
|
||||
yAxes: [
|
||||
{
|
||||
gridLines: { drawBorder: true, display: false },
|
||||
display: true,
|
||||
stacked: true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setColorblind() {
|
||||
this.isColorblind = !this.isColorblind;
|
||||
}
|
||||
|
||||
formatDataAnswers(){
|
||||
|
||||
formatDataAnswers(poll) {
|
||||
if (poll && poll.pollType === "special dates") {
|
||||
this.initPollCounter();
|
||||
poll.answers.forEach(response => {
|
||||
switch (response.text) {
|
||||
case "yes":
|
||||
this.yesList[this.nbPoll - 1]++;
|
||||
break;
|
||||
case "maybe":
|
||||
this.maybeList[this.nbPoll - 1]++;
|
||||
break;
|
||||
case "no":
|
||||
this.noList[this.nbPoll - 1]++;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
initPollCounter() {
|
||||
this.nbPoll++;
|
||||
this.dateList[this.nbPoll -1] = "jeudi";
|
||||
this.maybeList[this.nbPoll - 1] = 0;
|
||||
this.yesList[this.nbPoll - 1] = 0;
|
||||
this.noList[this.nbPoll - 1] = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user