Issue
I'm not good in javascript. I have google charts with data. And I need to add data to charts via loop in javascript:
for (let i = 0; i < 3; i++) {
data.addRow(
['{{list[i][0]}}',
{ v: {{list[i][1][0]}}, f: '{{list[i][1][1]}}' }]
);
}
What did contain a list:
list = ['Car', [2:30, '2:30'], '1:00']
But it wrote me an error:
UndefinedError
jinja2.exceptions.UndefinedError: list object has no element Undefined
Can you advice me please, what I can do with it?
Solution
I'm not too familiar with the Google Charts API, but from the looks of it, you have a syntax error since you're literally passing the string '{{list[i][0]}}'
to the data.addrow()
method.
Try this instead and let me know if it works:
for (let i = 0; i < 3; i++) {
data.addRow([
list[i][0],
{
v: list[i][1][0],
f: list[i][1][1]
}
]);
}
Answered By - timpa
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.