Line 16.4, I keep getting this error stating the following: Expected an identifier and instead How do I fix this? Any help would be much appreciated. Thanks.
var ctx = document.getElementById("myChart").getContext("2d");
var myChart = new Chart(ctx, {
type: "polarArea",
data: {
labels: ["HTML", "JQUERY", "JAVASCRIPT", "PYTHON", "CSS", "RUBY", "API"],
datasets: [{
backgroundColor: [
"#adddcf",
"#3498db",
"#e8e7e5",
"#bfb1d5",
"#f0e0a2",
"#fed1be",
"#777777"
],
data: [93, 67, 80, 73, 87, 38, 65],
}]
}
});
new Chart(ctx, {
data: data,
type: "polarArea",
options: options
});
"Other suggestions" are probably limited to "complete JSLinting the file". ;^) First, read up on JSLint directives to figure out how to keep some of the stuff that it's complaining about.
It's not that difficult for this file, thankfully.
document, you have to let JSLint know that it's working in a browser with browser:true. white:true for "messy whitespace". Chart is never defined. The global directive tells JSLint that Chart is defined somewhere else, is in your global scope already, and is fine to use here.data and options in your new Chart call have to come from somewhere, so it's going to yell about that, obviously.In the end, this lints...
/*jslint browser:true, white:true */
/*global Chart */
var ctx = document.getElementById("myChart").getContext("2d");
var myChart = new Chart(ctx, {
type: "polarArea",
data: {
labels: ["HTML", "JQUERY", "JAVASCRIPT", "PYTHON", "CSS", "RUBY", "API"],
datasets: [{
backgroundColor: [
"#adddcf",
"#3498db",
"#e8e7e5",
"#bfb1d5",
"#f0e0a2",
"#fed1be",
"#777777"
],
data: [93, 67, 80, 73, 87, 38, 65]
}]
}
});
var data = "something";
var options = "something else";
new Chart(ctx, {
data: data,
type: "polarArea",
options: options
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With