What is wrong in with my code? | XM Community
Skip to main content

Hi all,

I'm trying to create a graph as a feedback to my participants (what won't I do for their data...) but my code gives an error message (for phase 3), can anyone help me with this?
Phase 1 - Header HTML code

            integrity="sha256-rjYnB0Bull7k2XkbJ03UNGqMuMieR769uQVGSSlsi6A="

           crossorigin="anonymous"> 
Phase 2 - HTML code for creating a space for the chart
 
Phase 3 - graph data
var ctx = document.getElementById("myChart").getContext('2d');

var myChart = new Chart(ctx, {

    type: 'bar',

    data: {

        labels: "a", "b", "c", "d", "e"],

        datasets: {

            label: 'example',

            data: "1","2","3","4", "5"],

            backgroundColor:

                'rgba(255, 99, 132, 0.2)',

                'rgba(54, 162, 235, 0.2)',

                'rgba(255, 206, 86, 0.2)',

                'rgba(75, 192, 192, 0.2)’,

                'rgba(255, 159, 64, 0.2)'

            ],

            borderColor:

                'rgba(255,99,132,1)',

                'rgba(54, 162, 235, 1)',

                'rgba(255, 206, 86, 1)',

                'rgba(75, 192, 192, 1)’,

                'rgba(255, 159, 64, 1)'

            ],

            borderWidth: 1

        }]

    },

    options: {

        scales: {

            yAxes: {

                ticks: {

                            max: 7,

                            min: 0,

                    beginAtZero:true

                }

            }]

        }

    }

});

The error message I get is: Invalid JavaScript! You cannot save until you fix all errors: Unexpected token ILLEGAL

Can anyone help?
Have a good weekend!

Daniel

DanielSpitz You have a single quotation mark instead of an apostrophe in two places: the fourth item in backgroundColor and borderColor. They are both at the end of the line just before the comma. Change them to ( ' ) and you should be good.
                'rgba(255, 206, 86, 0.2)',

                'rgba(75, 192, 192, 0.2)’,


https://community.qualtrics.com/XMcommunity/discussion/comment/40264#Comment_40264Thank you, that solved it!
I can't believe I missed it (:


Leave a Reply