I’m a bit lost. Tried using handlebars to access data in an array - but it throws a test error.
I know we are supposed to edit this code:
onst vizData = {
// Labels take an array of strings
labels: res.report.portfolios.groups.data.symbol,
// Data takes an array of numbers
data: res.report.portfolios.groups.data.quantity
};
challenge 1: My code is in nested arrays. I need to iterate through multiple results to get each symbol and each quantity. Handlebars.js code does not seem to work here.
My data is more like (ignore the lack of quotes etc - my data is real json - this is for structure only:
Portfolios
- 0
– Groups
— Groupname: “United States”
— 0
-----Data
------ Symbol: A
------ Quantity: 1000
— 1
—Groupname: “Netherlands”
-----Data
------ Symbol: A_C
------ Quantity: 1000
// EDIT THIS OBJECT TO BIND YOUR DATA
const vizData = {
// Labels take an array of strings
labels:
{{#each res.report.portfolios}}
{{#each groups}}
{{#each data}}
{{symbol}}
{{/each}}
{{/each}}
{{/each}},
This also doesn’t work.
What does the chart use to access data - and is there an example where I can see it accessing data in an array rather than the relatively flat example? Is there recommended reading to figure out how to initialize the constant that has an example with a more complex array?
Is there instructions on the different pieces to change? I note mychart is referenced in the script and the const. Do I change both?
Thanks in advance