1👍
Your syntax won’t work in your first example in a couple places. There are some great tutorials out there. Most of your issues above come from the fact that you’re not assigning everything in your object to a key.
For example, you have a pattern of
var myObject = {
thing1: 'thing one',
{
thing2: 'thing two',
}, // etc
}
After the first comma, on the same line as 'thing one'
, you start another object. You need to assign that object to a key in the parent object.
var myObject = {
thing1: 'thing one',
secondObject: {
thing2: 'thing two',
}, // etc
}
But like I said, there are tons of resources out there for beginner JS. I’d start there before posting to SO.
- Chartjs-Laravel Charts Refresh With Ajax
- Chartjs-Is possible convert an associative array in indexed array in php?
0👍
Yes. The right-hand side of a name: property
pair in an object literal just needs to be an expression.
Your problems are caused by typos, not by the use of variables.
- JavaScript is case sensitive.
myData
andmydata
are different variable names - Variable assignments use
=
, not:
- Objects are constructed of
property: value
separated by commas. You forgot theproperty:
part sometimes and just had a value.
var abc = "123";
var myData = [123, 45, 67, 78, 89, 123];
var verycomplexstruct = {
this: abc,
something: {
that: myData,
something_else: {}
}
};
console.log(verycomplexstruct);
- Chartjs-How to get multiple elements on a page using flask (tables, pie charts, etc.)
- Chartjs-Can't call any function inside of onClick function chart.js
Source:stackexchange.com