我无法找到创建highcharts服务器的好教程。他们的安装页面似乎没有所需的东西。
http://docs.highcharts.com/#installation
这个github页面看起来更接近我需要的东西,但我对Tomcat很新,并且无法跟踪它
https://github.com/highslide-software/highcharts.com/tree/master/exporting-server/java
到目前为止我所拥有的:
#!/bin/bash
#allow access for tomcat
/sbin/iptables -I INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
echo "[OK]"
echo -n "Saving new rules"
(/etc/init.d/iptables save && echo "[OK]") || echo "[FAILED]"
service iptables restart
yum -y install tomcat6*
yum -y install java-1.7.0-openjdk java-1.7.0-openjdk-devel
service tomcat6 start
chkconfig --levels 35 tomcat6 on
wget http://download.nextag.com/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
tar -xzvf apache-maven-3.0.5-bin.tar.gz
mv apache-maven-3.0.5/ /usr/local/
echo 'export PATH=/usr/local/apache-maven-3.0.5/bin:$PATH' >> /etc/profile.d/maven.sh
yum -y install freetype freetype-devel
yum -y install fontconfig fontconfig-devel
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
tar -xjvf phantomjs-1.9.0-linux-x86_64.tar.bz2
yum -y install ant-* ant-apache* ant-commons-logging
yum -y install git
git clone https://github.com/highslide-software/highcharts.com.git
cd highcharts.com
ant assemble
ant lint
ant build
我认为我需要编译highcharts,然后将其移动到tomcat目录/ var / lib / tomcat6 / webapps。但是当我运行ant build
时,我收到了一个错误 # ant build
Buildfile: build.xml
set.properties:
clean:
[mkdir] Created dir: /root/highcharts.com/build/dist/js/adapters
[mkdir] Created dir: /root/highcharts.com/build/dist/js/modules
[mkdir] Created dir: /root/highcharts.com/build/dist/highcharts/gfx
[mkdir] Created dir: /root/highcharts.com/build/dist/highcharts/js/adapters
[mkdir] Created dir: /root/highcharts.com/build/dist/highcharts/js/modules
[mkdir] Created dir: /root/highcharts.com/build/dist/highstock/gfx
[mkdir] Created dir: /root/highcharts.com/build/dist/highstock/js/adapters
[mkdir] Created dir: /root/highcharts.com/build/dist/highstock/js/modules
[mkdir] Created dir: /root/highcharts.com/build/tests
[mkdir] Created dir: /root/highcharts.com/build/coverage-report
assemble:
check-crlf:
do-lint:
lint:
minify:
compile:
BUILD FAILED
/root/highcharts.com/build.xml:378: The following error occurred while executing this line:
/root/highcharts.com/build.xml:336: java.lang.ClassNotFoundException: org.apache.bsf.engines.javascript.JavaScriptEngine
Total time: 9 seconds
但老实说,我甚至不确定我是否正确地走这条路。我是在正确的轨道上吗?有什么建议吗?
答案 0 :(得分:1)
看起来我完全走错了路。我不需要安装tomcat,java或其中任何一个。我安装了fonts,phantomjs和highcharts,并可以通过apache发送Web请求来生成图表。
这是我的设置脚本:
#!/bin/bash
/sbin/iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
echo "[OK]"
echo -n "Saving new rules"
(/etc/init.d/iptables save && echo "[OK]") || echo "[FAILED]"
service iptables restart
service httpd start
chkconfig --levels 35 httpd on
yum -y install urw-fonts
wget -O /root/phantomjs-1.9.0-linux-x86_64.tar.bz2
https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
tar -C /root/ -xjvf /root/initial_install/phantomjs-1.9.0-linux-x86_64.tar.bz2
cp /root/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/bin/
cd /var/www/html
wget http://www.highcharts.com/downloads/zips/Highcharts-3.0.1.zip
unzip Highcharts-3.0.1.zip
mkdir /var/www/html/exporting-server/phantomjs/tmp
chmod 777 /var/www/html/exporting-server/phantomjs/tmp
perl -pi -e 's/phantomjs\/highcharts-convert.js/\/var\/www\/html\/exporting-server\/phantomjs\/highcharts-convert.js/g' /var/www/html/exporting-server/php/php-phantomjs/index.php
perl -pi -e "s/phantomjs\/tmp/\/var\/www\/html\/exporting-server\/phantomjs\/tmp/g" /var/www/html/exporting-server/php/php-phantomjs/index.php
perl -pi -e "s/highstock.js/\/var\/www\/html\/exporting-server\/java\/highcharts-export\/src\/main\/webapp\/WEB-INF\/phantomjs\/highstock.js/g" /var/www/html/exporting-server/phantomjs/highcharts-convert.js
perl -pi -e "s/highstock-more.js/\/var\/www\/html\/js\/highcharts-more.js/g" /var/www/html/exporting-server/phantomjs/highcharts-convert.js
perl -pi -e "s/jquery-1.8.2.min.js/\/var\/www\/html\/exporting-server\/java\/highcharts-export\/src\/main\/webapp\/WEB-INF\/phantomjs\/jquery-1.8.2.min.js/g" /var/www/html/exporting-server/phantomjs/highcharts-convert.js
以下是可以生成图表的示例PHP:
(从/exporting-server/php/php-phantomjs/demo.html填写$ hc_options和$ hc_svg)
<?php
$url = 'http://highcharts-server/exporting-server/php/php-phantomjs/index.php';
$filename = 'test.png';
$hc_options = <<<EOF
EOF;
$hc_svg = <<<EOF
EOF;
$hc_type = 'image/png';
$hc_width = '600';
$hc_scale = '';
$hc_product = 'highcharts';
$hc_callback = "function(){alert('hallo from highcharts')}";
$post_data = array('options'=>$hc_options,'svg'=>$hc_svg,'type'=>$hc_type,'width'=>$hc_width,'scale'=>$hc_scale,'product'=>$hc_product,'callback'=>$hc_callback);
$curl_data = http_build_query($post_data);
$options[CURLOPT_RETURNTRANSFER] = true; // return web page
$options[CURLOPT_HEADER] = false; // don't return headers
$options[CURLOPT_FOLLOWLOCATION] = true; // follow redirects
$options[CURLOPT_ENCODING] = ""; // handle all encodings
$options[CURLOPT_USERAGENT] = "ap testing highcharts"; // who am i
$options[CURLOPT_AUTOREFERER] = true; // set referer on redirect
$options[CURLOPT_CONNECTTIMEOUT] = 10; // timeout on connect
$options[CURLOPT_TIMEOUT] = 20; // timeout on response
$options[CURLOPT_MAXREDIRS] = 10; // stop after 10 redirects
$options[CURLOPT_POST] = 1; // i am sending post data
$options[CURLOPT_POSTFIELDS] = $curl_data; // the post data in get format (e.g. name=Bob&age=12
$options[CURLOPT_SSL_VERIFYHOST] = 0;
$options[CURLOPT_SSL_VERIFYPEER] = false;
#$options[CURLOPT_VERBOSE] = 1; // outputs the web page
$ch = curl_init($url);
curl_setopt_array($ch,$options);
$content = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch) ;
$header = curl_getinfo($ch);
curl_close($ch);
file_put_contents($filename, $content);
?>