0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails✖️Prawn✖️Gruff のただのメモ

Posted at

Gruff::new


def spider_graph_report(building)
  #参考に
  #https://d.conma.me/entry/20081011/1223736412
    stroke_axis
    #平均点をハッシュで返す
    @score = building.parts.group(:part_type).average(:score)
    g = Gruff::Spider.new(7, '535x400')
    # タイトル
    #g.title = '部位ごとの点数'
    # 使うフォント
    #g.font = File.expand_path('artwork/fonts/meiryo.ttc', RAILS_ROOT)
    g.font = "vendor/fonts/ipaexg.ttf"
    # グラフの目盛りの最大値
    g.maximum_value = 6.0
    # グラフの目盛りの最小値
    g.minimum_value = 0
    g.no_data_message = 'データがありません'
    @score.each do |key ,value|
      value = value.to_f
      g.data "#{key}", [value]
    end
    g.data "壁10", [5.5]
    g.data "壁10", [6.5]
    g.data "壁10", [5.5]
    g.data "壁10", [4.5]

    # g.theme = {
    #   :colors => ['black', 'grey'],
    #   :marker_color => 'grey',
    #   :font_color => 'black',
    #   :background_colors => 'transparent'
    # }

    #g.theme_rails_keynote
    g.theme_keynote

    # g.theme_37signals
    # g.theme_greyscale
    # g.theme_keynote
    # g.theme_odeo
    # g.theme_pastel
    #g.theme_rails_keynote

    g.bottom_margin = 80
    g.top_margin = 60
    #g.title_font_size = 70
    g.legend_font_size = 35
    # marker_font_size
    # title_font_size グラフのタイトルのフォントサイズ
    # legend_font_size  凡例のフォントサイズ
    # legend_box_size 凡例のサイズ

    #ファイルとして置く
    #g.write(filename=File.expand_path('graphs/status.png', RAILS_ROOT))

    # うまくいかなかったらこっちで
    # #g.write("tankyou#{g.object_id}.png")
    # #image "tankyou#{g.object_id}.png"
    # 画像の表示

    #graphsフォルダ配下に画像を保存
    g.write(filename=File.expand_path("graphs/#{g.object_id}.png"))
    image "graphs/#{g.object_id}.png"
end

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?