欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot整合Echarts繪制靜態(tài)數(shù)據(jù)柱狀圖和餅圖

 更新時(shí)間:2024年03月04日 10:34:38   作者:jy02268879  
這篇文章給大家介紹了SpringBoot整合Echarts繪制靜態(tài)數(shù)據(jù)柱狀圖和餅圖,文中通過代碼示例給大家介紹的非常詳細(xì),具有一定的參考價(jià)值,需要的朋友可以參考下

Echarts官網(wǎng)

idea創(chuàng)建spring boot項(xiàng)目

下載echarts

把echarts.min.js文件放到項(xiàng)目中。

項(xiàng)目目錄

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>com.sid.spark</groupId>
    <artifactId>webspark</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
 
    <name>webspark</name>
    <description>Demo project for Spring Boot</description>
 
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
 
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>
 
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
 
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
 
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
    </dependencies>
 
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
 
 
</project>
application.properties

配置項(xiàng)目訪問端口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名字一樣,返回這個(gè)界面
 
    }
 
    @RequestMapping(value="/courseClickCount",method = RequestMethod.GET)
    public ModelAndView courseClickCountStat(){
 
        return new ModelAndView("demo");//跟templates文件夾下的demo.html名字一樣,返回這個(gè)界面
 
    }
}

test.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- 引入 ECharts 文件 -->
    <script src="js/echarts.min.js"></script>
</head>
<body>
<!-- 為 ECharts 準(zhǔn)備一個(gè)具備大?。▽捀撸┑?DOM -->
<div id="main" style="width: 600px;height:400px;position:absolute;top:50%;left: 50%;margin-top: -200px;margin-left: -300px;"></div>
 
<script type="text/javascript">
    // 基于準(zhǔn)備好的dom,初始化echarts實(shí)例
    var myChart = echarts.init(document.getElementById('main'));//main是<div id="main" style="width: 600px;height:400px;"></div>的id
 
    // 指定圖表的配置項(xiàng)和數(shù)據(jù)
    var option = {
        title: {
            text: 'ECharts 入門示例'
        },
        tooltip: {},
        legend: {
            data:['銷量']
        },
        xAxis: {
            data: ["襯衫","羊毛衫","雪紡衫","褲子","高跟鞋","襪子"]
        },
        yAxis: {},
        series: [{
            name: '銷量',
            type: 'bar',
            data: [5, 20, 36, 10, 10, 20]
        }]
    };
 
    // 使用剛指定的配置項(xiàng)和數(shù)據(jù)顯示圖表。
    myChart.setOption(option);
</script>
</body>
</html>

demo.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Demo</title>
    <!-- 引入 ECharts 文件 -->
    <script src="js/echarts.min.js"></script>
</head>
<body>
<!-- 為 ECharts 準(zhǔn)備一個(gè)具備大?。▽捀撸┑?DOM -->
<div id="main" style="width: 600px;height:400px;position:absolute;top:50%;left: 50%;margin-top: -200px;margin-left: -300px;"></div>
 
<script type="text/javascript">
    // 基于準(zhǔn)備好的dom,初始化echarts實(shí)例
    var myChart = echarts.init(document.getElementById('main'));//main是<div id="main" style="width: 600px;height:400px;"></div>的id
 
    // 指定圖表的配置項(xiàng)和數(shù)據(jù)
    var option = {
        title : {
            text: 'Spark Streaming實(shí)戰(zhàn)課程訪問量實(shí)時(shí)統(tǒng)計(jì)',
            subtext: '實(shí)戰(zhàn)課程訪問次數(shù)',
            x:'center'
        },
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/> : {c} (vvxyksv9kd%)"
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: ['Spark SQL實(shí)戰(zhàn)','Hadoop基礎(chǔ)','Storm實(shí)戰(zhàn)','Spark Streaming實(shí)戰(zhàn)','理論']
        },
        series : [
            {
                name: '訪問次數(shù)',
                type: 'pie',
                radius : '55%',
                center: ['50%', '60%'],
                data:[
                    {value:3350, name:'Spark SQL實(shí)戰(zhàn)'},
                    {value:3100, name:'Hadoop基礎(chǔ)'},
                    {value:2340, name:'Storm實(shí)戰(zhàn)'},
                    {value:1350, name:'Spark Streaming實(shí)戰(zhàn)'},
                    {value:15480, name:'理論'}
                ],
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
 
 
    // 使用剛指定的配置項(xiàng)和數(shù)據(jù)顯示圖表。
    myChart.setOption(option);
</script>
</body>
</html>

運(yùn)行項(xiàng)目

訪問http://localhost:9999/sid/hello

http://localhost:9999/sid/first

http://localhost:9999/sid/courseClickCount

以上就是SpringBoot整合Echarts繪制靜態(tài)數(shù)據(jù)柱狀圖和餅圖的詳細(xì)內(nèi)容,更多關(guān)于SpringBoot Echarts繪制柱狀圖和餅圖的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 解決Properties屬性文件中的值有等號(hào)和換行的小問題

    解決Properties屬性文件中的值有等號(hào)和換行的小問題

    這篇文章主要介紹了解決Properties屬性文件中的值有等號(hào)有換行的小問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-08-08
  • SpringBoot自定義錯(cuò)誤處理邏輯詳解

    SpringBoot自定義錯(cuò)誤處理邏輯詳解

    這篇文章主要介紹了SpringBoot自定義錯(cuò)誤處理邏輯,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2022-10-10
  • SpringBoot中maven項(xiàng)目打成war包部署在linux服務(wù)器上的方法

    SpringBoot中maven項(xiàng)目打成war包部署在linux服務(wù)器上的方法

    這篇文章主要介紹了SpringBoot中maven項(xiàng)目打成war包部署在linux服務(wù)器上的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-05-05
  • Java的Channel通道之FileChannel類詳解

    Java的Channel通道之FileChannel類詳解

    這篇文章主要介紹了Java的Channel通道之FileChannel類詳解,FileChannel類是Java NIO中的一個(gè)重要類,用于在文件中進(jìn)行讀寫操作,它提供了一種高效的方式來處理大文件和隨機(jī)訪問文件的需求,需要的朋友可以參考下
    2023-10-10
  • SpringBoot使用Redis緩存的實(shí)現(xiàn)方法

    SpringBoot使用Redis緩存的實(shí)現(xiàn)方法

    這篇文章主要介紹了SpringBoot使用Redis緩存的實(shí)現(xiàn)方法,需要的朋友可以參考下
    2018-02-02
  • java數(shù)組中的異常類型整理

    java數(shù)組中的異常類型整理

    在本篇文章里小編給各位分享的是一篇關(guān)于java數(shù)組中的異常類型整理內(nèi)容,有興趣的朋友們可以學(xué)習(xí)下。
    2021-02-02
  • Java 數(shù)據(jù)庫連接池 DBCP 的介紹

    Java 數(shù)據(jù)庫連接池 DBCP 的介紹

    這篇文章主要給大家分享的是 Java 數(shù)據(jù)庫連接池 DBCP 的介紹, 是 Apache 旗下 Commons 項(xiàng)目下的一個(gè)子項(xiàng)目,提供連接池功能DBCP,下面來看看文章的具體介紹內(nèi)容吧,需要的朋友可以參考一下
    2021-11-11
  • 談?wù)凧ava中整數(shù)類型(short int long)的存儲(chǔ)方式

    談?wù)凧ava中整數(shù)類型(short int long)的存儲(chǔ)方式

    在java中的整數(shù)類型有四種,分別是byte short in long,本文重點(diǎn)給大家介紹java中的整數(shù)類型(short int long),由于byte只是一個(gè)字節(jié)0或1,在此就不多說了,對java中的整數(shù)類型感興趣的朋友一起學(xué)習(xí)吧
    2015-11-11
  • springboot項(xiàng)目中application.properties無法變成小樹葉問題解決方案

    springboot項(xiàng)目中application.properties無法變成小樹葉問題解決方案

    這篇文章主要介紹了springboot項(xiàng)目中application.properties無法變成小樹葉問題解決,本文通過圖文實(shí)例代碼相結(jié)合給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-09-09
  • SpringBoot實(shí)現(xiàn)獲取客戶端IP地理位置

    SpringBoot實(shí)現(xiàn)獲取客戶端IP地理位置

    在當(dāng)今互聯(lián)的世界中,了解客戶端的地理位置對于提供個(gè)性化服務(wù)和增強(qiáng)用戶體驗(yàn)至關(guān)重要,使用本文為大家介紹了SpringBoot獲取客戶端IP地理位置的相關(guān)方法,需要的小伙伴可以參考下
    2023-11-11

最新評論