gpt4 book ai didi

javascript - Highcharts 和表达式语言问题 - token "{"出现语法错误

转载 作者:行者123 更新时间:2023-12-03 07:25:08 24 4
gpt4 key购买 nike

我正在使用 highCharts 中的以下脚本,并且尝试使用 jsp 和 EL 使提供给图表的数据动态化。但是,当我尝试使用 EL 替换数字字段时,我收到错误 “ token “{”上的语法错误,.expected”

请找到下面的代码片段

<script src="jquery.min.js"></script>
<script>
$(function() {

// Create the chart
$('#resourceutilization')
.highcharts(
{
chart : {
type : 'column'
},
credits : {
enabled : false
},
title : {
text : 'Resource Utilization'
},
subtitle : {
text : 'Project name : '
},
xAxis : {
type : 'category'
},
yAxis : {
title : {
text : 'Percentage Resource share'
}

},
legend : {
enabled : false
},
plotOptions : {
series : {
borderWidth : 0,
dataLabels : {
enabled : true,
format : '{point.y:.1f}%'
}
}
},

tooltip : {
headerFormat : '<span style="font-size:11px">{series.name}</span><br>',
pointFormat : '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},

series : [ {
name : 'Resources',
colorByPoint : true,
data : [ {
name : '${drillDownProject.resourceName[0]}',
y : ${drillDownProject.resourceContrib[0]}, // Issue here . This is a number
}, {
name : '${drillDownProject.resourceName[1]}',
y : ${drillDownProject.resourceContrib[1]}, // and here. This is a number
}, {
name : '',
y : 0,
}, {
name : '',
y : 0,
}, {
name : '',
y : 0,
} ],
} ],
//Drill down start
// Drill Down End
});
});
</script>

最佳答案

您可以尝试放入 JS 变量并检查,

<script type="text/javascript">
var resourceName = '${drillDownProject.resourceName[0]}';
var contribution = '${drillDownProject.resourceContrib[0]}';

....

{
name : resourceName,
y : contribution,
},

</script>

确保您使用的是 Servlet 2.4 或更高版本。检查 web.xml 的 servlet 版本。 BalusC已回答how-to-pass-an-el-variable-to-javascript 。另请检查this .

关于javascript - Highcharts 和表达式语言问题 - token "{"出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36035762/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com