これはドキュメントに記載されています:
You can set a theme manually. Assign a hash to this method before you send your data.
graph.theme = {
:colors => %w(orange purple green white red),
:marker_color => 'blue',
:background_colors => %w(black grey)
}
:background_image => 'squirrel.png' is also possible.
(Or hopefully something better looking than that.)
ソースはより役に立ちますが:
# File 'lib/gruff/base.rb', line 300
def theme=(options)
reset_themes()
defaults = {
:colors => ['black', 'white'],
:additional_line_colors => [],
:marker_color => 'white',
:font_color => 'black',
:background_colors => nil,
:background_image => nil
}
@theme_options = defaults.merge options
@colors = @theme_options[:colors]
@marker_color = @theme_options[:marker_color]
@font_color = @theme_options[:font_color] || @marker_color
@additional_line_colors = @theme_options[:additional_line_colors]
render_background
end
colors
おそらく問題はあなたの属性だと思います:colors => ['#A5D8D8', '#EFAD1C']
--ショーン・フロスト・デューク・ジャクソンが述べたように、それadd_color('#c0e9d3')
を行うには使用する必要があるようですが、テーマをインラインで定義している場合、ドキュメントはどこでそれを行うかが明確ではありません. THEMES
モジュールに独自のテーマを追加する方が簡単かもしれません:
LUIGIS_THEME = {
:colors => [
'#A5D8D8',
'#EFAD1C'
],
:marker_color => '#55ae36',
:font_color => 'black',
:background_colors => 'white'
}
次に、これが呼び出されますg.theme = Gruff::Themes::LUIGIS_THEME