将包含自定义文本的多个高分辨率图导出为pdf [英] Export Multiple highcharts with custom text into pdf
本文介绍了将包含自定义文本的多个高分辨率图导出为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用PDF格式的textareas导出多个图表我可以在以上代码中实现如何实现? pLease引导我
解决方案
您可以使用我以前的想法,从类似的主题:
导出为pdf格式的自由文本导出高图
您可以迭代所有图表,并将它们添加到导出的svg中,并使用与这些图表相关的文本:
Highcharts .getSVG =函数(图表,文本){
var svgArr = [],
top = 0,
width = 0,
txt;
Highcharts.each(图表,函数(图表,i){
var svg = chart.getSVG();
svg = svg.replace('< svg','< g ($'$');
top + = chart.chartHeight;
width = Math.max(width,chart.chartWidth);
svgArr.push(svg);
txt = texts [i];
txt = '< text x =''+ 0 +'y ='+(top + 20)+'styles ='+ txt.attributes.style.value +'>'+ $(txt)。 val()+'< / text>';
top + = 60;
svgArr.push(txt);
});
return'< svg height ='+ top +'width ='+ width +'version =1.1xmlns =http://www.w3.org/2000/svg> ;'+ svgArr.join('')+'< / svg>';
};
您可以在这里找到一个例子: http://jsfiddle.net/6m2rneL8/32/
I want to export multiple charts with textareas in PDF i
How will I implement in the following above code? pLease guide me
解决方案
You can use my previous idea from similar topic: Export highchart with free text entered as pdf
You can iterate over all of your charts and add them to your exported svg with texts related to these charts:
Highcharts.getSVG = function(charts, texts) {
var svgArr = [],
top = 0,
width = 0,
txt;
Highcharts.each(charts, function(chart, i) {
var svg = chart.getSVG();
svg = svg.replace('<svg', '<g transform="translate(0,' + top + ')" ');
svg = svg.replace('</svg>', '</g>');
top += chart.chartHeight;
width = Math.max(width, chart.chartWidth);
svgArr.push(svg);
txt = texts[i];
txt = '<text x= "' + 0 + '" y = "' + (top + 20) + '" styles = "' + txt.attributes.style.value + '">' + $(txt).val() + '</text>';
top += 60;
svgArr.push(txt);
});
return '<svg height="' + top + '" width="' + width + '" version="1.1" xmlns="http://www.w3.org/2000/svg">' + svgArr.join('') + '</svg>';
};
Here you can find an example how it can work: http://jsfiddle.net/6m2rneL8/32/
这篇关于将包含自定义文本的多个高分辨率图导出为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文