Spring Boot整合Echarts绘制静态数据柱状图、饼图

Echarts官网

idea创建spring boot项目

Spring Boot整合Echarts绘制静态数据柱状图、饼图_第1张图片

Spring Boot整合Echarts绘制静态数据柱状图、饼图_第2张图片

Spring Boot整合Echarts绘制静态数据柱状图、饼图_第3张图片

下载echarts

Spring Boot整合Echarts绘制静态数据柱状图、饼图_第4张图片

把echarts.min.js文件放到项目中。

项目目录

Spring Boot整合Echarts绘制静态数据柱状图、饼图_第5张图片

 

pom.xml



    4.0.0

    com.sid.spark
    webspark
    0.0.1-SNAPSHOT
    jar

    webspark
    Demo project for Spring Boot

    
        org.springframework.boot
        spring-boot-starter-parent
        2.0.3.RELEASE
         
    

    
        UTF-8
        UTF-8
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        

        
            org.springframework.boot
            spring-boot-starter-thymeleaf
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    



application.properties

配置项目访问端口9999,配置前缀/sid

server.port=9999
server.servlet.context-path=/sid
HelloSpringBoot.java
package com.sid.spark.webspark;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
public class HelloSpringBoot {

    @RequestMapping(value="/hello",method = RequestMethod.GET)
    public String sayHello(){

        return "Hello Spring Boot!";

    }

    @RequestMapping(value="/first",method = RequestMethod.GET)
    public ModelAndView firstDemo(){

        return new ModelAndView("test");//跟templates文件夹下的test.html名字一样,返回这个界面

    }

    @RequestMapping(value="/courseClickCount",method = RequestMethod.GET)
    public ModelAndView courseClickCountStat(){

        return new ModelAndView("demo");//跟templates文件夹下的demo.html名字一样,返回这个界面

    }
}

test.html




    
    Title
    
    



demo.html




    
    Demo
    
    



运行项目

访问http://localhost:9999/sid/hello

Spring Boot整合Echarts绘制静态数据柱状图、饼图_第6张图片

http://localhost:9999/sid/first

Spring Boot整合Echarts绘制静态数据柱状图、饼图_第7张图片

 

http://localhost:9999/sid/courseClickCount

Spring Boot整合Echarts绘制静态数据柱状图、饼图_第8张图片

你可能感兴趣的:(spark,streaming,spring,boot,echarts)