   robot.respond /.*達成度.*/i, (msg) ->
     user = msg.envelope.user.name
     data = robot.brain.data.goals[user] or null
+    embed_user = user
 
     unless data and data.attempted
-      msg.send "#{user}さんのデータはありません。"
-      return
+      embed_user = null
+      msg.send "#{user}さんのデータはありませんが。。"
 
-    attempted = data.attempted
-    achieved = data.achieved
-    rate = Math.round achieved / attempted * 100
+    user_goals_data = robot.brain.data.goals
 
-    review = reviews[Math.floor rate / 20]
+    user_rates = {}
+    for _user, _data of user_goals_data
+      attempted = _data.attempted
+      achieved = _data.achieved
+      rate = getRate achieved, attempted
+      user_rates[_user] = rate
 
-    msg.send "#{user}さんの目標達成度は、" +
-      "#{rate}%（#{achieved} / #{attempted}）です！\n" +
-      review
+    user_rates["test"] = 87
+    user_rates["test2"] = 33
+
+    chart_url = getBarCharUrl user_rates, embed_user
+
+    unless data and data.attempted
+      msg.send "皆さんの目標達成度のチャートです。\n" +
+        chart_url
+    else
+      rate = getRate data.achieved, data.attempted
+      review = reviews[Math.floor rate / 20]
+      msg.send "#{user}さんの目標達成度は、" +
+        "#{rate}%" +
+        "（#{data.achieved} / #{data.attempted}）です！\n" +
+        review + "\n" +
+        chart_url
+
+  getRate = (achieved, attempted) ->
+    Math.round achieved / attempted * 100
+
+  getBarCharUrl = (user_rates, embed_user) ->
+    Quiche = require "quiche"
+    bar = new Quiche "bar"
+    bar.setWidth 400
+    bar.setHeight 50 + 20 * _.keys(user_rates).length
+    bar.setTitle "目標達成度"
+    bar.setBarHorizontal()
+    bar.setBarWidth 10
+    bar.setBarSpacing 5
+    bar.setLegendLeft()
+    bar.setTransparentBackground()
+
+    if embed_user?
+      index = parseInt Math.random() * colors.length, 10
+      embed_color = colors[index]
+
+    for user, rate of user_rates
+      if embed_user?
+        if user is embed_user
+          color = embed_color
+        else
+          color = "95a5a6"
+      else
+        index = parseInt Math.random() * colors.length, 10
+        color = colors[index]
+      bar.addData [rate], user, color
+
+    bar.addData [100], "神", "95a5a6"
+
+    bar.addAxisLabels('x', [0, 25, 50, 75, 100])
+
+    bar.getUrl true


    msg.send "OK。#{user}さんの今日の目標は「#{goal}」ですね。"

  robot.respond /今日の目標は？/i, (msg) ->
    user = msg.envelope.user.name
    data = robot.brain.data.goals[user] or null


#   hubot 今日の目標は〜 - 今日の目標を設定します。期限は同日午前3時です。
#   hubot 今日の目標は？ - 今日の目標を表示します。
#   hubot 目標達成 - 目標を達成したことを hubot に知らせます。
#   hubot 達成度 - 目標の達成度を hubot に聞きます。

moment = require "moment"
_ = require "underscore"

