C# 将highchart中的html表导出为pdf格式,但其显示不带html设计
在Highchart中,标题和副标题均以表格格式显示,但C# 将highchart中的html表导出为pdf格式,但其显示不带html设计,c#,highcharts,export-to-pdf,C#,Highcharts,Export To Pdf,在Highchart中,标题和副标题均以表格格式显示,但 当我试图将highchart中的html表导出为pdf格式时,它的显示没有html设计 <script type="text/javascript"> createGraph({ chart: { renderTo: 'container', defaultSeriesType: 'line',
当我试图将highchart中的html表导出为pdf格式时,它的显示没有html设计
<script type="text/javascript">
createGraph({
chart: {
renderTo: 'container',
defaultSeriesType: 'line',
margin: [140, 150, 60, 80],
events: {}
},
credits: {
enabled: false // remove highcharts.com
},
colors: ['#009999', '#0000FF', '#6600CC','#006600','#CC0000'],
title: {
align: 'left',
style: {
color: '#6600CC',
fontWeight: 'bold',
fontSize: '14px'
},
text:'<table style="color: #0000FF">'+
'<tr><td>'+<%= Parameter%> +'</td></tr>'+
'<tr><td>'+<%= PCode%> +'</td></tr>'+
'<tr><td>'+<%= PName%> +'</td></tr>'+
'</table>',
useHTML: true
},
subtitle: {
align: 'left',
style: {
color: '#6600CC',
fontWeight: 'bold',
fontSize: '14px'
},
text:'<table class="TFtableCol2">'+
'<tr><td>'+<%= HMean%> +'</td>' +
'<td>'+<%= HSTD%> +'</td>' +
'<td>'+<%= HRSD%> +'</td>' +
'<td>'+<%= HUCL%> +'</td>' +
'<td>'+<%= HLCL%> +'</td>' +
'</tr>'+
'<tr><td>'+<%= SDose%> +'</td>' +
'<td>'+'Spec Type :'+<%= SpecType%> +'</td>'+
'<td>'+<%= SPValue%> +'</td>'+
'<td>'+<%= SHLimit%> +'</td>'+
'<td>'+<%= SLLimit%> +'</td>'+
'</tr>'+
'</table>',
useHTML: true
},
xAxis: {
categories: <%= LotNumber%> ,
title: {
text: 'Lot #'
}
},
yAxis: {
title: {
text: 'Concentration ('+<%= Unit%>+')'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y +' '+ <%= Unit%>;
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: 0,
y: 100
},
series:[{
name: 'Spec '+ <%= SpecType%> ,
data: <%= SpecValue%>
},
{
name: 'Series',
data: <%= Series%>
},
{
name: 'Mean',
data: <%= Mean%>
},
{
name: 'UCL',
data: <%= UCL%>
},
{
name: 'LCL',
data: <%= LCL%>
}]
});
function createGraph(chartOptions) {
// open the basic chart
$(document).ready(function () {
// set the click event for the parent chart
chartOptions.chart.events.click = function () {
hs.htmlExpand(document.getElementById(chartOptions.chart.renderTo), {
width: 9999,
height: 9999,
allowWidthReduction: true,
preserveContent: false
}, {
chartOptions: chartOptions
});
};
var chart = new Highcharts.Chart(chartOptions);
});
}
// Create a new chart on Highslide popup open
hs.Expander.prototype.onAfterExpand = function () {
if (this.custom.chartOptions) {
var chartOptions = this.custom.chartOptions;
if (!this.hasChart) {
chartOptions.chart.renderTo = $('.highslide-body')[0];
chartOptions.chart.events.click = function () {};
var hsChart = new Highcharts.Chart(chartOptions);
}
this.hasChart = true;
}
};
</script>
createGraph({
图表:{
renderTo:'容器',
defaultSeriesType:“行”,
保证金:[140、150、60、80],
事件:{}
},
学分:{
已启用:false//remove highcharts.com
},
颜色:[“009999”、“0000FF”、“6600CC”、“006600”、“CC0000”],
标题:{
对齐:“左”,
风格:{
颜色:“#6600CC”,
fontWeight:'粗体',
字体大小:“14px”
},
文本:“”+
''+ +''+
''+ +''+
''+ +''+
'',
useHTML:true
},
副标题:{
对齐:“左”,
风格:{
颜色:“#6600CC”,
fontWeight:'粗体',
字体大小:“14px”
},
文本:“”+
''+ +'' +
''+ +'' +
''+ +'' +
''+ +'' +
''+ +'' +
''+
''+ +'' +
''++'规格类型:'++''+
''+ +''+
''+ +''+
''+ +''+
''+
'',
useHTML:true
},
xAxis:{
类别:,
标题:{
正文:“地段”
}
},
亚克斯:{
标题:{
正文:“浓度(+')”
},
绘图线:[{
值:0,
宽度:1,
颜色:'#808080'
}]
},
工具提示:{
格式化程序:函数(){
返回“+this.series.name+”
“+this.x+”:“+this.y+”;
}
},
图例:{
布局:“垂直”,
对齐:“右”,
垂直排列:“顶部”,
x:0,,
y:100
},
系列:[{
名称:“规范”+,
数据:
},
{
名称:'系列',
数据:
},
{
名称:'平均',
数据:
},
{
名称:“UCL”,
数据:
},
{
名称:“LCL”,
数据:
}]
});
函数createGraph(图表选项){
//打开基本图表
$(文档).ready(函数(){
//设置父图表的单击事件
chartOptions.chart.events.click=函数(){
hs.htmlExpand(document.getElementById(chartOptions.chart.renderTo){
宽度:9999,
身高:9999,
AllowWidthReduce:true,
内容:false
}, {
图表选项:图表选项
});
};
var图表=新的Highcharts.chart(图表选项);
});
}
//在Highslide弹出窗口打开时创建新图表
hs.Expander.prototype.onAfterExpand=函数(){
if(this.custom.chartOptions){
var chartOptions=this.custom.chartOptions;
如果(!this.hasChart){
chartOptions.chart.renderTo=$('.highslide body')[0];
chartOptions.chart.events.click=函数(){};
var hsChart=新的Highcharts.Chart(图表选项);
}
this.hasChart=true;
}
};
图形显示如下
但在PDF格式中是这样的
我如何解决我的问题
请帮忙
谢谢Highcharts导出服务器仅使用SVG导出图像<代码>使用HTML则不起作用。请参阅:
缺点是,它总是放在所有其他SVG内容的顶部,并且在导出的图表中呈现的方式不同。
@PawełFus是否有其他方式在图形和pdf中设置表格请使用内置的Highcharts方法帮助?不。使用SVG(Highcharts.renderer)创建该表,或者使用不同的工具将SVG+HTML导出到PDF。