Chart.js在jsp文件里报错,求解
js代码
<script type="text/javascript">
$(function(){
var data = [
{
value: [25,100,1000],
color:"#c11611",
label: "主题酒"
},
{
value: [25,100,1000],
color :"#efa82d",
label: "坛藏酒"
},
{
value: [18,80,800],
color: "#d05905",
label: "专享酒"
},
{
value: [18,80,800],
color: "#dfd304",
label: "皇宫酒"
},
{
value: [14,70,700],
color: "#eeeeee",
label: "其他酒"
}
];
var ctx = document.getElementById("chart-area").getContext("2d");
var myNewChart = new Chart(ctx).Doughnut(data,{
segmentShowStroke : true,
segmentStrokeColor : "transparent",
segmentStrokeWidth : 0,
percentageInnerCutout : 82,
animationSteps : 100,
animationEasing : "easeOutBounce",
animateRotate : true,
animateScale : false,
//String - A legend template
legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for(var i=0; i<segments.length; i++){%><li><span class=\"lump\" style=\"background-color:<%=segments[i].fillColor%>;\"></span><span class=\"wh160 ellips\"><%if(segments[i].label){%><%=segments[i].label%><%}%>:<%if(segments[i].label){%><%=segments[i].value[0]%><%}%>%</span><span class=\"wh80 ellips\"><%if(segments[i].label){%><%=segments[i].value[1]%><%}%>箱</span><span class=\"wh140 ellips\">销售额:¥<%if(segments[i].label){%><%=segments[i].value[2]%><%}%></span></li><%}%></ul>"
});
var _html = myNewChart.generateLegend();
$(".plan_rt").append(_html);
for(var i=0;i<data.length; i++){
myNewChart.segments[i].value = data[i].value[0];
}
myNewChart.update();
})
</script>
主要报错是这段代码:
legendTemplate : "<ul class="<%=name.toLowerCase()%>-legend"><% for(var i=0; i<segments.length; i++){%><li><span class="lump" style="background-color:<%=segments[i].fillColor%>;"></span><span class="wh160 ellips"><%if(segments[i].label){%><%=segments[i].label%><%}%>:<%if(segments[i].label){%><%=segments[i].value[0]%><%}%>%</span><span class="wh80 ellips"><%if(segments[i].label){%><%=segments[i].value[1]%><%}%>箱</span><span class="wh140 ellips">销售额:¥<%if(segments[i].label){%><%=segments[i].value[2]%><%}%></span></li><%}%></ul>"
报错信息
segments cannot be resolved to a variable
哪位大大知道原因?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论