55 lines
2.1 KiB
JavaScript
55 lines
2.1 KiB
JavaScript
//For now create dummy data to show on the website.
|
|
let dummydata1 = [40, 30, 20];
|
|
let questionOptionsDummy1 = ['disgusting','clean', 'fine'];
|
|
|
|
let dummydata2 = [25, 35, 40];
|
|
let questionOptionsDummy2 = ['disgusting', 'clean', 'normal'];
|
|
|
|
let dummydata3 = [30, 20, 20];
|
|
let questionOptionsDummy3 = ['cold', 'perfect', 'hot'];
|
|
|
|
let dummydata4 = [30, 20, 20];
|
|
let questionOptionsDummy4 = ['really crowded','not at all', 'its fine', ];
|
|
|
|
let dummydata5 = [30, 20, 20];
|
|
let questionOptionsDummy5 = ['no','yes', 'decently'];
|
|
|
|
//make arrays to store data.
|
|
let chartConfigArray = [];
|
|
let textArray = [];
|
|
|
|
let questionArray = [];
|
|
let questionOptionsDummy = [];
|
|
let dummydata = [];
|
|
|
|
//Go along the array's to fetch data, and push this in a class.
|
|
for (let i = 0; i < 5; i++) {
|
|
dummydata.push(dummydata1, dummydata2, dummydata3, dummydata4, dummydata5);
|
|
questionOptionsDummy.push(questionOptionsDummy1, questionOptionsDummy2, questionOptionsDummy3, questionOptionsDummy4, questionOptionsDummy5);
|
|
|
|
questionArray.push(new QuestionCreationClass(dummydata[i], questionOptionsDummy[i]));
|
|
}
|
|
|
|
//Go allong another array to also give the class that creates the charts the data collected by the previous array.
|
|
for (let i = 0; i < 5; i++){
|
|
textArray.push('Question 1 Responses', 'Question 2 Responses', 'Question 3 Responses', 'Question 4 Responses', 'Question 5 Responses');
|
|
|
|
chartConfigArray.push(new ChartConfigClass(questionArray[i].questionData, textArray[i]));
|
|
}
|
|
|
|
// Create the charts
|
|
const ctx1 = document.getElementById('chart1').getContext('2d');
|
|
const myChart1 = new Chart(ctx1, chartConfigArray[0].chartConfig);
|
|
|
|
const ctx2 = document.getElementById('chart2').getContext('2d');
|
|
const myChart2 = new Chart(ctx2, chartConfigArray[1].chartConfig);
|
|
|
|
const ctx3 = document.getElementById('chart3').getContext('2d');
|
|
const myChart3 = new Chart(ctx3, chartConfigArray[2].chartConfig);
|
|
|
|
const ctx4 = document.getElementById('chart4').getContext('2d');
|
|
const myChart4 = new Chart(ctx4, chartConfigArray[3].chartConfig);
|
|
|
|
const ctx5 = document.getElementById('chart5').getContext('2d');
|
|
const myChart5 = new Chart(ctx5, chartConfigArray[4].chartConfig);
|