javascript, js chart looping issues

36 Views Asked by At

Below code works fine for 3 students data that is hard coded. I need to generalise it to work with any number of students.

Making a stack column bar chart report using jscharts.

var barChartData = {
            labels: ['1A', '1B', '1C', '1D', '1E', '1F'],
            datasets: [{
                label: student_name[0],
                backgroundColor: window.chartColors.red,
                stack: 'Stack 0',
                data: [
                    oneA[0],
                    oneB[0],
                    oneC[0],
                    oneD[0],
                    oneE[0],
                    oneF[0] 
                ]
},
{
                label: student_name[1],
                backgroundColor: window.chartColors.blue,
                stack: 'Stack 0',
                data: [
                    oneA[1],
                    oneB[1],
                    oneC[1],
                    oneD[1],
                    oneE[1],
                    oneF[1] 
                ]
},
{
                label: student_name[2],
                backgroundColor: window.chartColors.yellow,
                stack: 'Stack 0',
                data: [
                    oneA[2],
                    oneB[2],
                    oneC[2],
                    oneD[2],
                    oneE[2],
                    oneF[2] 
                ]
} 


]}
0

There are 0 best solutions below