ソースを参照

Added another line chart format

Andrew Kane 9 年 前
コミット
96b2360646
1 ファイル変更3 行追加0 行削除
  1. 3 0
      app/views/blazer/queries/run.html.erb

+ 3 - 0
app/views/blazer/queries/run.html.erb

@@ -9,6 +9,9 @@
     <% if values.size >= 2 and values.first.is_a?(Time) and values[1..-1].all?{|v| v.is_a?(Numeric) } %>
       <% time_k = @columns.keys.first %>
       <%= line_chart @columns.keys[1..-1].map{|k| {name: k, data: @rows.map{|r| [r[time_k], r[k]] }} } %>
+    <% elsif values.size == 3 and values.first.is_a?(Time) and values[1].is_a?(String) and values[2].is_a?(Numeric) %>
+      <% keys = @columns.keys %>
+      <%= line_chart @rows.group_by { |v| v[keys[1]] }.map { |name, v| {name: name, data: v.map { |v2| [v2[keys[0]], v2[keys[2]]] } } } %>
     <% elsif values.size == 2 and values.first.is_a?(String) and values.last.is_a?(Numeric) %>
       <%= pie_chart @rows.map(&:values), library: {sliceVisibilityThreshold: 1 / 40.0} %>
     <% end %>