Skip to content

Commit 1162d0f

Browse files
committed
Spring Boot 2.x基础教程:使用 ECharts 绘制折线图
1 parent 5a75730 commit 1162d0f

File tree

7 files changed

+145
-1
lines changed

7 files changed

+145
-1
lines changed

2.1.x/chapter4-2/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
HELP.md
2+
/target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
.sts4-cache
13+
14+
### IntelliJ IDEA ###
15+
.idea
16+
*.iws
17+
*.iml
18+
*.ipr
19+
20+
### NetBeans ###
21+
/nbproject/private/
22+
/nbbuild/
23+
/dist/
24+
/nbdist/
25+
/.nb-gradle/
26+
/build/
27+
28+
### VS Code ###
29+
.vscode/

2.1.x/chapter4-2/pom.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>org.springframework.boot</groupId>
8+
<artifactId>spring-boot-starter-parent</artifactId>
9+
<version>2.1.3.RELEASE</version>
10+
<relativePath/> <!-- lookup parent from repository -->
11+
</parent>
12+
13+
<groupId>com.didispace</groupId>
14+
<artifactId>chapter4-2</artifactId>
15+
<version>0.0.1-SNAPSHOT</version>
16+
17+
<properties>
18+
<java.version>1.8</java.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-web</artifactId>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.projectlombok</groupId>
34+
<artifactId>lombok</artifactId>
35+
<scope>provided</scope>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-test</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-maven-plugin</artifactId>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
54+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.didispace.chapter42;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Chapter42Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Chapter42Application.class, args);
11+
}
12+
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.didispace.chapter42;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.ui.ModelMap;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
7+
@Controller
8+
public class HelloController {
9+
10+
@GetMapping("/")
11+
public String index(ModelMap map) {
12+
// return模板文件的名称,对应src/main/resources/templates/index.html
13+
return "index";
14+
}
15+
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8" />
5+
<title>Spring Boot中使用ECharts</title>
6+
<script src="https://cdn.bootcss.com/echarts/4.6.0/echarts.min.js"></script>
7+
</head>
8+
<body>
9+
<div id="main" style="width: 1000px;height:400px;"></div>
10+
</body>
11+
12+
<script type="text/javascript">
13+
let myChart = echarts.init(document.getElementById('main'));
14+
let option = {
15+
title: {
16+
text: 'Spring Boot中使用ECharts'
17+
},
18+
tooltip: {},
19+
xAxis: {
20+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
21+
},
22+
yAxis: {},
23+
series: [{
24+
data: [820, 932, 901, 934, 1290, 1330, 1320],
25+
type: 'line'
26+
}]
27+
};
28+
myChart.setOption(option);
29+
</script>
30+
</html>

2.1.x/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
<module>chapter3-4</module>
2828

2929
<!-- Web开发 -->
30-
<module>chapter4-1</module> <!-- Spring Boot中使用 ECharts -->
30+
<module>chapter4-1</module> <!-- 使用 Thymeleaf开发Web页面 -->
31+
<module>chapter4-2</module> <!-- 使用 ECharts 绘制折线图 -->
3132

3233
</modules>
3334

0 commit comments

Comments
 (0)