<?php
/**
* This file is part of the exporting module for Highcharts JS.
* www.highcharts.com/license
*
*
* Available POST variables:
*
* $filename string The desired filename without extension
* $type string The MIME type for export.
* $width int The pixel width of the exported raster image. The height is calculated.
* $svg string The SVG source code to convert.
*/
// Options
define ('BATIK_PATH', 'batik-rasterizer.jar');
///////////////////////////////////////////////////////////////////////////////
ini_set('magic_quotes_gpc', 'off');
$type = $_POST['type'];
$svg = (string) $_POST['svg'];
$filename = (string) $_POST['filename'];
// prepare variables
if (!$filename) $filename = 'chart';
if (get_magic_quotes_gpc()) {
$svg = stripslashes($svg);
}
$tempName = md5(rand());
// allow no other than predefined types
if ($type == 'image/png') {
$typeString = '-m image/png';
$ext = 'png';
} elseif ($type == 'image/jpeg') {
$typeString = '-m image/jpeg';
$ext = 'jpg';
} elseif ($type == 'application/pdf') {
$typeString = '-m application/pdf';
$ext = 'pdf';
} elseif ($type == 'image/svg+xml') {
$ext = 'svg';
}
$outfile = "temp/$tempName.$ext";
if (isset($typeString)) {
// size
if ($_POST['width']) {
$width = (int)$_POST['width'];
if ($width) $width = "-w $width";
}
// generate the temporary file
if (!file_put_contents("temp/$tempName.svg", $svg)) {
die("Couldn't create temporary file. Check that the directory permissions for
the /temp directory are set to 777.");
}
// do the conversion
$output = shell_exec("java -jar ". BATIK_PATH ." $typeString -d $outfile $width temp/$tempName.svg");
// catch error
if (!is_file($outfile) || filesize($outfile) < 10) {
echo "<pre>$output</pre>";
echo "Error while converting SVG. ";
if (strpos($output, 'SVGConverter.error.while.rasterizing.file') !== false) {
echo "
<h4>Debug steps</h4>
<ol>
<li>Copy the SVG:<br/><textarea rows=5>" . htmlentities(str_replace('>', ">\n", $svg)) . "</textarea></li>
<li>Go to <a href='http://validator.w3.org/#validate_by_input' target='_blank'>validator.w3.org/#validate_by_input</a></li>
<li>Paste the SVG</li>
<li>Click More Options and select SVG 1.1 for Use Doctype</li>
<li>Click the Check button</li>
</ol>";
}
}
// stream it
else {
header("Content-Disposition: attachment; filename=\"$filename.$ext\"");
header("Content-Type: $type");
echo file_get_contents($outfile);
}
// delete it
unlink("temp/$tempName.svg");
unlink($outfile);
// SVG can be streamed directly back
} else if ($ext == 'svg') {
header("Content-Disposition: attachment; filename=\"$filename.$ext\"");
header("Content-Type: $type");
echo $svg;
} else {
echo "Invalid type";
}
?>
没有合适的资源?快使用搜索试试~ 我知道了~
Highstock-1.1.6
共46个文件
htm:27个
js:15个
png:2个
5星 · 超过95%的资源 需积分: 9 422 下载量 159 浏览量
2012-06-29
22:26:58
上传
评论
收藏 311KB ZIP 举报
温馨提示
兼容当今所有的浏览器,包括iPhone、IE和火狐等等; 对于非商用用户免费(包括个人网站、非盈利性组织、学生团体等)。 纯JS,无BS; 支持大部分的图表类型:直线图,曲线图、区域图、区域曲线图、柱状图、饼装图、散布图; 跨语言:不管是PHP、.net还是Java都可以使用,它只需要三个文件:一个是
资源推荐
资源详情
资源评论
收起资源包目录
Highstock-1.1.6.zip (46个子文件)
js
highstock.js 144KB
highstock.src.js 461KB
themes
dark-blue.js 4KB
skies.js 2KB
grid.js 2KB
gray.js 4KB
dark-green.js 4KB
adapters
mootools-adapter.js 2KB
prototype-adapter.js 3KB
prototype-adapter.src.js 10KB
mootools-adapter.src.js 8KB
modules
exporting.js 7KB
canvas-tools.js 57KB
canvas-tools.src.js 98KB
exporting.src.js 17KB
index.htm 2KB
exporting-server
index.php 3KB
graphics
skies.jpg 42KB
snow.png 5KB
sun.png 4KB
examples
ohlc
index.htm 1KB
basic-line
index.htm 955B
yaxis-reversed
index.htm 1KB
scrollbar-disabled
index.htm 1007B
line-markers
index.htm 1KB
flags-shapes
index.htm 2KB
candlestick
index.htm 1KB
markers-only
index.htm 1KB
column
index.htm 1KB
area
index.htm 1KB
yaxis-plotlines
index.htm 1KB
intraday-candlestick
index.htm 1KB
lazy-loading
index.htm 3KB
data-grouping
index.htm 2KB
navigator-disabled
index.htm 1007B
flags-placement
index.htm 2KB
styled-scrollbar
index.htm 1KB
candlestick-and-volume
index.htm 2KB
flags-general
index.htm 2KB
areaspline
index.htm 1KB
dynamic-update
index.htm 2KB
spline
index.htm 1KB
yaxis-plotbands
index.htm 1KB
compare
index.htm 2KB
intraday-area
index.htm 1KB
step-line
index.htm 1KB
共 46 条
- 1
zhaohui534
- 粉丝: 2
- 资源: 59
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页