简体   繁体   English

Ruby axlsx 饼图标题字号

[英]Ruby axlsx pie chart title font size

I'm using the axslx ruby gem to create a spreadsheet with a pie chart.我正在使用 axslx ruby gem 创建带有饼图的电子表格。 For the most part it is very straightforward and I've had no problems with one exception: I can't figure out how to set the font size for the title in the pie chart.在大多数情况下,它非常简单,我没有遇到任何问题,但有一个例外:我不知道如何设置饼图中标题的字体大小。 I've read through the documentation and examples and found no mention of it.我已经阅读了文档和示例,但没有提到它。 I'm sure I have overlooked it but if anyone knows how to do that, I would appreciate any help.我确定我忽略了它,但如果有人知道如何做到这一点,我将不胜感激。

thanks!谢谢!

adding code... sorry, should have provided this initially添加代码......对不起,最初应该提供这个

issue_sheet.add_chart(Axlsx::Pie3DChart, start_at: 'I3', end_at: 'S32') do |chart|
    chart.add_series data: issue_sheet['G3:G7'], labels: issue_sheet['F3:F7'], colors: ['9467BD','D62828','EF7E12','82BBDD','3AA02B']
    chart.title = "Distribution by Severity"
    chart.d_lbls.show_val = false
    chart.d_lbls.show_percent = true
    chart.d_lbls.d_lbl_pos = :outEnd
    chart.d_lbls.show_leader_lines = true
end

I did notice something interesting but I'm not sure what it means.我确实注意到了一些有趣的事情,但我不确定这意味着什么。 If I use a cell reference rather than a string for the chart.title, the font size changes.如果我使用单元格引用而不是chart.title 的字符串,则字体大小会发生变化。

chart.title = "Distribution by Severity" # this sets the font size to 16
chart.title = issue_chart['F2'] # this sets the font size to 10

You can make use of sz property provided in this link您可以使用此链接中提供的 sz 属性

item_style = s.add_style :b => false, :sz => 9,  :font_name => 'courier'
row = sheet.add_row [item.name, item.price], :style => item_style

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM