我是smarty
的新手我希望在图表上显示数据的循环我的代码图如下所示,例如,数据仅用于一条记录,我希望它用于array
。下面提到的数组的位置和数组位于smarty
类型array
中,因此我将如何将其与jquery
集成到我的图表中。
<script type="text/javascript">
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "Simple Chart",
fontSize: 30
},
animationEnabled: true,
axisX:{ gridColor: "Silver",
tickColor: "silver",
valueFormatString: "DD/MMM"
},toolTip:{shared:true},
theme: "theme2",
axisY: {
gridColor: "Silver",
tickColor: "silver"
},legend:{
verticalAlign: "center",
horizontalAlign: "right"
},data: [ /* want iteration for loop as smarty array */
{type: "line",
showInLegend: true,
lineThickness: 2,
name: "Visits",
markerType: "square",
color: "#F08080",
dataPoints: [
{ x: new Date(2010,0,3), y: 650 },
{ x: new Date(2010,0,5), y: 700 },
{ x: new Date(2010,0,7), y: 710 },
{ x: new Date(2010,0,9), y: 658 },
{ x: new Date(2010,0,11), y: 734 },
{ x: new Date(2010,0,13), y: 963 },
{ x: new Date(2010,0,15), y: 847 },
{ x: new Date(2010,0,17), y: 853 },
{ x: new Date(2010,0,19), y: 869 },
{ x: new Date(2010,0,21), y: 943 },
{ x: new Date(2010,0,23), y: 970 }
]
} /* loop will end here */
],
legend:{
cursor:"pointer",
itemclick:function(e){
if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
}
else{
e.dataSeries.visible = true;
}
chart.render();
}
}
});
chart.render();
}
</script>
如上所述,我想在此代码中使用数据循环