我在Rails应用程序中使用gruff以及Prawn PDF将图形插入可下载的PDF中。但是我在显示的图形质量上有一些问题。有谁知道如何纠正?它只有360像素宽。
大虾代码
name = @result.each do |v| v.variety.variety_name end
lint = @result.map {|v| v.lint/227 }
g = Gruff::Bar.new(360)
g.data(:lint, lint, '#00463f')
@results.each do |item|
g.title = "#{item.site.site_name} Variety Summary Graph"
g.title_font_size = 24
end
g.labels = {}
@result.each_with_index do |v, i|
g.labels[i] = v.variety.variety_name
g.y_axis_label = 'Yield (bales/ha)'
g.marker_font_size = 24
g.marker_count = 5
g.theme = {:marker_color => '#000000', :font_color => '#000000', :background_colors => %w(#ffffff #ffffff)}
g.minimum_value = 0
g.hide_legend = true
end
g.write("#{Rails.root}/app/assets/images/chart/chart.png")
image "#{Rails.root}/app/assets/images/chart/chart.png"
您遭受与我自己相似的痛苦。因为我的宽度只有400像素,但是又低又低,因为答案可能在您的代码之内!
g = Gruff::Bar.new(360)
因为那里有360个,不能没有800个吗?
g = Gruff :: Bar.new(800)
现在,您所要做的就是命令您的虾来缩放您的形象。
image "graph.png", :scale => 0.68
要进一步了解您的虾,请阅读以下页面:模块:大虾::图像
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句