jquery - 无法在 jquery HighCharts 中显示 ModelMap 对象数据
问题描述
' 在我的控制器方法中:
下面的代码将返回带有一组记录的数据,其中包含 3 个字段
1 Fruits 30
2 Vegetables 40 .... 等等
这里我想在 HighCharts 图中显示第二列和第三列 '
List<Object[]> vendingTypesCount = svService.getVendingTypeWiseVendorsCount();
Map<String,Object> mp = new LinkedHashMap<String,Object>(); // mp is LinkedHashMap object
for (Object[] objects : vendingTypesCount) {
mp.put(objects[1].toString(), objects[2]);
}
// checked in Java, data is getting accessed perfectly
map.addAttribute("vendingTypesData",mp); // here map is the ModelMap object
// 在我的 Jsp 中:
<figure class="highcharts-figure">
<div id="container2"></div>
<p class="highcharts-description">
</p>
</figure>
<script type="text/javascript">
Highcharts.chart('container2', {
chart: {
type: 'column'
},
title: {
text: 'Vending Types Data '
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: [[${vendingTypeData.keySet()}]], // data not getting accessed,
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Number of Vendors'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [[${vendingTypeData.values()}]] // data is not getting accessed
});
解决方案
推荐阅读
- r - R - 子集()中的逻辑运算符是一个字符串
- python - Python Packaging: user specified file path
- json - VM2233:1 未捕获(承诺中)SyntaxError:JSON 中位置 0 的意外标记 s
- python - 如何在python中将图像内容居中
- javascript - 如何使用复选框显示多个下拉选择的值被选中
- jquery - 引导日期选择器中特定范围之间的禁用日期
- python - Python模块cli bash:找不到命令
- cmake - 当某些系统头文件(在 /usr/include 下)更新时,如何让我的 cmake 项目重新编译?
- python - Mac m1,rtree 0.9.7,空间索引 1.9.3,未找到符号
- php - 尝试在表单列表上创建返回按钮