5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/metrics-graphics-rails/view_helpers.rb', line 5
def metrics_graphic_for(data, options = {})
@data = data
json_data = data.to_json
@target = options.fetch(:target)
@x_accessor = options.fetch(:x_accessor) { :date }
@y_accessor = options.fetch(:y_accessor) { :value }
title = options.fetch(:title)
description = options.fetch(:description) { '' }
width = options.fetch(:width) { 600 }
height = options.fetch(:height) { 250 }
@time_format = options.fetch(:time_format) { '%Y-%m-%d' }
@markers = options.fetch(:markers) { [] }
@is_multiple = data.first.is_a?(Array)
= options[:extra_options] || {}
javascript_tag " var data = \#{json_data};\n\n \#{convert_data_js}\n \n \#{markers}\n\n MG.data_graphic({\n title: \"\#{title}\",\n description: \"\#{description}\",\n data: data,\n width: \#{width},\n height: \#{height},\n target: '\#{@target}',\n \#{extra_options_to_options}\n \#{markers_option}\n x_accessor: '\#{@x_accessor}',\n y_accessor: '\#{@y_accessor}'\n });\n SCRIPT\nend\n"
|