我正在尝试使用wicked_pdf,wkhtmltopdf-binary gems在rails中在pdf文件中打印高图表。在Gemfile中,我添加了这两个gem。下面是我的index.pdf.erb
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag "https://code.highcharts.com/highcharts.js" %>
<%= javascript_include_tag "https://code.highcharts.com/modules/exporting.js" %>
<%= javascript_include_tag "https://code.highcharts.com/modules/export-data.js" %>
<% @products.each do |product| %>
<%= product.name %>
<% end %>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
<script>
Highcharts.chart('container', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Browser market shares in January, 2018'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
animation: false,
pie: {
animation: false,
enableMouseTracking: false,
shadow: false,
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
#{request.format == 'pdf' ? 'enableMouseTracking: false, shadow: false, animation: false' : nil}
name: 'Brands',
colorByPoint: true,
data: [{
name: 'Chrome',
y: 61.41,
sliced: true,
selected: true
}, {
name: 'Internet Explorer',
y: 11.84
}]
}]
});
</script>
,但高图未在pdf文件中呈现。谁能帮我这个忙。