在Highcharts中,你有一个内置的按钮可以下载当前图表(例如:http://www.highcharts.com/demo/,这个按钮:)。你可以将它保存为PNG、JPEG、PDF或SVG。
我想做的是创建一个链接,将图像保存到服务器上,而不是下载它。我该怎么做?
我猜我必须修改exporting.src.js文件中的exportChart
函数。它看起来像这样(但我不知道如何用javascript实现):
exportChart: function (options, chartOptions) {
var form,
chart = this,
svg = chart.getSVG(chartOptions);
// merge the options
options = merge(chart.options.exporting, options);
// create the form
form = createElement('form', {
method: 'post',
action: options.url
}, {
display: NONE
}, doc.body);
// add the values
each(['filename', 'type', 'width', 'svg'], function (name) {
createElement('input', {
type: HIDDEN,
name: name,
value: {
filename: options.filename || 'chart',
type: options.type,
width: options.width,
svg: svg
}[name]
}, null, form);
});
// submit
form.submit();
// clean up
discardElement(form);
},
demo.js
https://github.com/ariya/phantomjs/blob/master/examples/phantomwebintro.js调用它即可。 - gakhovpage.open('http://yourdomain.org/your.php', function (status) { var content = page.content; console.log('Content: ' + content); phantom.exit(); });
http://phantomjs.org/api/webpage/property/content.html - gakhovjs/jquery.min.js
。 - gakhov