我是javascript的初学者。我想使用amcharts绘制图形。该信息来自webSql中的循环。原始情况下,一切工作正常,但是我尝试在JavaScript代码中插入生成循环的函数,但没有任何效果。谢谢您的帮助。
db.transaction(function(tx){ var my_query =“ SELECT” + id_resultat +“,COUNT(” + id_resultat +“)作为total_resultat,来自resultat_enquetes INNER JOIN的响应在响应上响应。id_reponse= resultat_enquetes。” + id_resultat +“ GROUP BY” + id_resultat;“
tx.executeSql(my_query, [], function (tx, results) {
var len = results.rows.length, i;
for (i = 0; i < len; i++) {
var reponse=results.rows.item(i).reponse;
var total_resultat=results.rows.item(i).total_resultat;
x="{'rep':'"+reponse+"','visits':"+total_resultat+",'color': '#FF0F00'}," ;
console.log(x);
}
});
});
无功图;
var chartData = [
//// BEGIN ----- HERE IS THE INFORMATION TO REPLACE PAR THE LOOP
{'rep':'Peu satisfait','visits':1,'color': '#FF0F00'},
{'rep':'Pas satisfait','visits':2,'color': '#FF0F00'},
////结束-----这里是替换循环的信息 ];
var chart = AmCharts.makeChart("chartdiv", {
type: "serial",
dataProvider: chartData,
categoryField: "rep",
depth3D: 20,
angle: 30,
categoryAxis: {
labelRotation: 45,
gridPosition: "start"
},
valueAxes: [{
title: "Visitors"
}],
graphs: [{
valueField: "visits",
//colorField: "color",
type: "column",
lineAlpha: 0,
fillAlphas: 1
}],
chartCursor: {
cursorAlpha: 0,
zoomable: false,
categoryBalloonEnabled: false
},
"export": {
"enabled": true
}
});
这就是我得到的错误:未捕获的SyntaxError:意外的令牌;