gpt4 book ai didi

java - 我如何使用 highchart 在 jsp 中的 spring mvc 中绘制图形

转载 作者:行者123 更新时间:2023-12-02 00:44:18 25 4
gpt4 key购买 nike

我想在jsp unsando spring mvc和highchart中绘制图形,但我仍然做不到,我等待您的答复,谢谢

我的观点,这是我想绘制图表的地方,但图表没有显示,它什么也没显示

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Chart</title>
<script src="resources/assets/js/highcharts.js"></script>
<script src="resources/assets/js/highcharts-3d.js"></script>
<!-- <script src="resources/assets/js/jquery.js"></script> -->
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>

</head>

<body class="page-container-bg-solid">
<div class="page-container">
<div class="page-content-wrapper">
<div class="page-head" style="background-color:#eff3f8;padding-top:40px">
<div class="container">
<div class="row" style="margin-bottom:30px">
<div class="col-md-6">
<h1>my Chart</h1>
</div>
</div>
<div class="row" style="margin-bottom:30px">
<div class="col-md-6" style="margin-top:20px">
<div id="mychart" style="width:100%; height:400px;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
Highcharts.setOptions({
global: {
useUTC: false
}
});
drawSalesByTypeChart();
drawSalesByRegionChart();
});


function drawSalesByRegionChart() {
var salesByRegionChart = Highcharts.chart('mychart', {
chart: {
type: 'pie',
margin: 40,
options3d: {
enabled: true,
alpha: 45,
beta: 0
}
},
title: {
text: 'Sales by Region'
},
plotOptions: {
pie: {
allowPointSelect: true,
depth: 35
}
},
series: [{
name: 'Regions',
colorByPoint:true,
data: [{
name: 'Northeast',
y: [[${listGraph}]]
}
]
}]
});
}
</script>
</body>
</html>

我的 Controller

@RequestMapping(value = "/graphReport")
public String combo(QcReport qc, Model model) throws IOException {
List<QcReport> listGraph = assayServ.listGraphAssay();
model.addAttribute("listGraph", listGraph);
return ("graphReport");
}

最佳答案

当我在下面的教程中比较您的工作时:

https://careydevelopment.us/2017/07/01/add-charts-spring-boot-app-highchart/

您正在尝试绘制饼图,在传递列表 ${listGraph} 时需要整数值。

                    series: [{ 
name: 'Regions',
colorByPoint:true,
data: [{
name: 'Northeast',
y: [[${listGraph}]]
}
]

关于java - 我如何使用 highchart 在 jsp 中的 spring mvc 中绘制图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57911769/

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