echart实现象形柱图
首先创建SpringBoot项目
在创建IndexController.java文件
package com.tqy.springboot.base.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class IndexController {
@GetMapping("/")
public String index(ModelMap map) {
//加入一个属性,用来在模板中读取
map.addAttribute("host", "内蒙古电子信息职业技术学院欢迎您!!!");
//return模板文件的名称,对应src\main\resources\templates\index.html
return "index";
}
@RequestMapping("/echarts")
public String echarts(){
return "echarts";
}
}
2、修改application.properties文件
server.port=8090
在创建echarts.html
echarts模型在https://echarts.apache.org/examples/zh/index.html找
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spring Boot中使用ECharts</title>
<script src="https://cdn.bootcss.com/echarts/4.6.0/echarts.min.js"></script>
</head>
<body>
<div id="main" style="width: 1000px;height:400px;"></div>
</body>
<script type="text/javascript">
var symbols = [
'path://M36.7,102.84c-1.17,2.54-2.99,4.98-3.39,7.63c-1.51,9.89-3.31,19.58-1.93,29.95 c0.95,7.15-2.91