温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

搭建Highcharts曲线图导出工具

发布时间:2020-06-10 22:16:31 来源:网络 阅读:1951 作者:chaodaibing 栏目:web开发

Highcharts是非常不错的页面曲线图工具,官网在https://www.highcharts.com/download/

问题就是如果工作环境是个封闭的内网,曲线图就无法正常导出,就需要搭建本地导出服务器


搭建方法如下:


官网介绍:https://www.hcharts.cn/docs/setting-up-the-server 

官方提供了两种方式 一种是npm安装 一种是git安装 

这里提供第一种,第二种我自己都没有成功过。


首先我们要找台能连接外网的独立服务器,先把环境包都装好。 


1.安装nodejs

wget https://npm.taobao.org/mirrors/node/latest-v8.x/node-v8.9.1-linux-x64.tar.xz  淘宝镜像

xz -d node-v8.9.1-linux-x64.tar.xz 

tar xf node-v8.9.1-linux-x64.tar       #直接得到编译好的二进制包

mv node-v8.9.1-linux-x64 /app/node

然后 vim /etc/profile

export NODE_HOME=/app/node

export PATH=$NODE_HOME/bin:$PATH

source /etc/profile  载入环境变量即可


验证  node -v 查看版本


2.安装highcharts模块

全局安装法

npm install -g cnpm --registry=https://registry.npm.taobao.org #启用淘宝镜像cnpm

cnpm install highcharts-export-server -g #于是自动装到/app/node/lib下面

#安装完毕后检查是否安装成功

highcharts-export-server


如此环境包都装好了,打包/app/node目录,然后移动到封闭环境的服务器上


3.启动服务器

vim config.cfg

{

"enableServer":1,

"port":3000,                             #对外端口

"workers":60,          #启动线程数目    如果开的太少导图会有重复的问题

"logLevel":4,  #日志等级  

“width":500,          #宽度             

"LogDest":"/tmp",                        #日志路径

"LogFile":"highcharts-export-server.log",#日志文件名称

}

cd /app/node/lib/node_modules/highcharts-export-server

highcharts-export-server --fromFile config.cfg


后台启动法

安装 pm2

npm install pm2 -g 

pm2 启动服务

cd /app/node/lib/node_modules/highcharts-export-server

pm2 start ./bin/cli.js --name highcharts-export -- --fromFile config.cfg

查看运行的进程

pm2 show highcharts-export

pm2 list     显示服务

pm2 monit 监控服务

pm2 stop/delete/kill  0/highcharts-export 停止服务


常见错误

SyntaxError: Use of const in strict mode.  

nodejs版本问题


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI