我想用textarea將多個highcharts導入多個pdf文件。 如何願買電子健康我轉換多個highcharts與文本區域以多個PDF $(函數(){ Highcharts.getSVG =函數(圖表,文本){ VAR svgArr = [], 頂= 0, 寬度= 0, TXT ; VAR SVG = chart.getSVG(); SVG = svg.replace( '', '');導出多個帶有文本區域的highcharts以將其高級圖表導出爲多個PDF文件
top += chart.chartHeight;
width = Math.max(width, chart.chartWidth);
svgArr.push(svg);
txt = '<text x= "' + 0 + '" y = "' + (top + 20) + '" styles = "' + text.attributes.style.value + '">' + $(text).val() + '</text>';
top += 200;
console.log(txt.indexOf('\n'))
svgArr.push(txt);
return '<svg height="' + top + '" width="' + width + '" version="1.1" xmlns="http://www.w3.org/2000/svg">' + svgArr.join('') + '</svg>';
};
Highcharts.getSVG = function(chart, text) {
var svgArr = [],
top = 0,
width = 0,
txt;
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 = '<text x= "' + 0 + '" y = "' + (top + 20) + '" styles = "' + text.attributes.style.value + '">' + $(text).val() + '</text>';
top += 200;
console.log(txt.indexOf('\n'))
svgArr.push(txt);
return '<svg height="' + top + '" width="' + width + '" version="1.1" xmlns="http://www.w3.org/2000/svg">' + svgArr.join('') + '</svg>';
};
Highcharts.exportChartWithText = function(chart, text, options) {
// Merge the options
options = Highcharts.merge(Highcharts.getOptions().exporting, options);
// Post to export server
Highcharts.post(options.url, {
filename: options.filename || 'chart',
type: options.type,
width: options.width,
svg: Highcharts.getSVG(chart, text)
});
};
Highcharts.exportChartWithText = function(chart, text, options) {
// Merge the options
options = Highcharts.merge(Highcharts.getOptions().exporting, options);
// Post to export server
Highcharts.post(options.url, {
filename: options.filename || 'chart',
type: options.type,
width: options.width,
svg: Highcharts.getSVG(chart, text)
});
};
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
categories: ['PreviousMonthutilizationforCPU', 'CurrentMonthUtilizationforCPU', 'Week2', 'Week2', 'Week3', 'Week4']
},
yAxis: {
min: 0,
title: {
text: 'POD'
}
},
tooltip: {
formatter: function() {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
data: [1, 2, 3, 3, 4]
}],
exporting: {
enabled: true
}
});
chart = new Highcharts.Chart({
chart: {
renderTo: 'container1',
type: 'column'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
categories: ['PreviousMonthutilizationforCPU', 'CurrentMonthUtilizationforCPU', 'Week2', 'Week2', 'Week3', 'Week4']
},
yAxis: {
min: 0,
title: {
text: 'POD'
}
},
tooltip: {
formatter: function() {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
data: [1, 2, 3, 3, 4]
}],
exporting: {
enabled: true
}
});
var text = document.getElementById('txt');
$("#export2pdf").click(function() {
Highcharts.exportChartWithText(chart, text, {
type: 'application/pdf',
filename: 'wow-pdf'
});
});
$("#export2pdf").click(function() {
Highcharts.exportChartWithText(chart, text, {
type: 'application/pdf',
filename: 'wow-pdf'
});
});
});
類似的話題:http://stackoverflow.com/questions/39171077/export-multiple-highcharts-with-custom -text-into-pdf –
如果我輸入如下文本區域1.自定義文本1 2.導出爲pdf時自定義Text2我得到1.自定義文本1 2.自定義Text2在一行中,而我需要打破線條和需要在另一行。請你指導我? –
我想要多個高分辨率到多個PDF文本區域。我的代碼如下,但沒有與上面的例子一起工作。 –