Flask Python - Google 图表 javascript 无法在 html 页面中将字符串作为参数传递

Flask Python - Google Chart javascript is not working passing string as parameter in html page

我的烧瓶应用程序中有这个字符串。

我正在为页面中的 google 图表传递此字符串,但它不起作用。有人可以帮助我吗?

我的 javascript 和 HTML 页面

arrayToDataTable 需要一个数组,而不是一个字符串。

您可以将字符串解析为 JSON...

JSON.parse(my_string)

var data2 = google.visualization.arrayToDataTable(JSON.parse(my_string));

但首先,您需要更改 所有 单引号...

['Month',  ...

双引号...

["Month",  ...