SpringBoot生成Echarts报表图片

SpringBoot + PhantomJS + ECharts 生成图表图片

PhantomJS安装

官网下载对应的安装包,然后配置环境变量即可。

Linux:

shell 复制代码
vi /etc/profile
export PATH=$PATH:/usr/local/phantomjs/bin

Windows

tex 复制代码
右键我的电脑->属性->高级系统设置->高级->环境变量
在 Path 添加 D:\Program Files\PhantomJS\bin\

测试是否安装成功:

shell 复制代码
#进入到example目录
cd example
#运行js脚本
phantomjs hello.js

通过PhantomJS启动Echarts

生成图片的核心脚本在于 echarts-convert.js ,里面会调用 echarts.min.js、jquery.min.js、china.js 三个脚本来生成echarts图表。

我们需要通过PhantomJS来启动Echarts服务

shell 复制代码
#进入目录
cd echartsconvert
#启动
phantomjs echarts-convert.js -s

编写代码生成图表文件

代码已放到gitlab,pull下来启动即可

相关推荐
wb043072011 天前
使用 Java 开发 MCP 服务并发布到 Maven 中央仓库完整指南
java·开发语言·spring boot·ai·maven
nbwenren1 天前
Springboot中SLF4J详解
java·spring boot·后端
helx821 天前
SpringBoot中自定义Starter
java·spring boot·后端
rleS IONS1 天前
SpringBoot获取bean的几种方式
java·spring boot·后端
lifewange1 天前
Go语言-开源编程语言
开发语言·后端·golang
白毛大侠1 天前
深入理解 Go:用户态和内核态
开发语言·后端·golang
R***z1011 天前
Spring Boot 整合 MyBatis 与 PostgreSQL 实战指南
spring boot·postgresql·mybatis
王码码20351 天前
Go语言中的数据库操作:从sqlx到ORM
后端·golang·go·接口
星辰_mya1 天前
雪花算法和时区的关系
数据库·后端·面试·架构师
赵丙双1 天前
spring boot AutoConfiguration.replacements 文件的作用
java·spring boot