rails-data-explorer 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/app/assets/images/rails-data-explorer/multiple_bivariate_small.png +0 -0
- data/lib/rails-data-explorer.rb +2 -0
- data/lib/rails-data-explorer/action_view_extension.rb +184 -2
- data/lib/rails-data-explorer/data_set.rb +4 -0
- data/lib/rails-data-explorer/engine.rb +16 -10
- data/lib/rails-data-explorer/exploration.rb +22 -6
- data/lib/rails_data_explorer.rb +94 -89
- data/rails-data-explorer.gemspec +1 -1
- data/vendor/assets/stylesheets/sources/rde-default-style.css +32 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b417c02b65c9c3f0fed2ddb85c5f6e992671aea
|
4
|
+
data.tar.gz: b0ff6ff26221174cf12ba739f5a6029ac636a0d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7badacd27cd2ed6059094d5aba6027918e342437c79ae938504b451c6572632c42d0abf1817c0ea7dc0e0c3083f037dd11acd455ab6e23784349908faf5a0c00
|
7
|
+
data.tar.gz: 597a4a2857756a8226582d69b3a2154ea1708e2c19a396a2cc94f2947d63a8126a8517b7242923d9b328384730bde98b3172a10a472ef8bc35d1d52d08daae20
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
there seems a huge inefficiency in RailsDataExplorer#build_exploration_from_data_series_specs
|
2
|
+
where we iterate over the entire data collection for every exploration.
|
3
|
+
|
4
|
+
|
5
|
+
### 0.2.3
|
6
|
+
|
7
|
+
* Don't show all explorations by default. Takes too long when having 100
|
8
|
+
explorations to render. Instead show univariate explorations by default
|
9
|
+
and bivariate explorations on demand.
|
10
|
+
|
1
11
|
### 0.2.2
|
2
12
|
|
3
13
|
* Fixed file inclusion bug that prevented loading of Gem
|
Binary file
|
data/lib/rails-data-explorer.rb
CHANGED
@@ -1,11 +1,193 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# Adds view helpers to ActionView
|
3
4
|
#
|
4
5
|
class RailsDataExplorer
|
5
6
|
module ActionViewExtension
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
# Renders the entire RailsDataExplorer view
|
9
|
+
# @param rails_data_explorer [RailsDataExplorer]
|
10
|
+
def rails_data_explorer(rde)
|
11
|
+
content_tag(:div, class: 'rails-data-explorer') do
|
12
|
+
[
|
13
|
+
rde_toc(rde.data_series_names, rde.explorations_with_charts_available),
|
14
|
+
rde_explorations_with_charts(rde.explorations_with_charts_to_render),
|
15
|
+
].join.html_safe
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns a url that can be used to reset the Filterrific params
|
20
|
+
def reset_filterrific_url(opts = {})
|
21
|
+
url_for(
|
22
|
+
{ filterrific: { reset_filterrific: true } }.merge(opts)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
# @param ds_names [Array<String>] the names of the data_series
|
29
|
+
# @param explorations [Array<Exploration>]
|
30
|
+
def rde_toc(ds_names, explorations)
|
31
|
+
reversed_ds_names = ds_names.reverse
|
32
|
+
num_cols = 2 + ds_names.length
|
33
|
+
content_tag(:div, class: 'rde panel panel-primary') do
|
34
|
+
content_tag(:div, class: 'panel-heading') do
|
35
|
+
%(<a name="rails_data_explorer-toc"></a>).html_safe +
|
36
|
+
content_tag(:h2, "List of data explorations", class: 'rde-exploration-title panel-title')
|
37
|
+
end +
|
38
|
+
content_tag(:div, class: 'panel-body') do
|
39
|
+
content_tag(:table, class: 'table rde_toc-matrix') do
|
40
|
+
# render header row for analysis types
|
41
|
+
content_tag(:tr) do
|
42
|
+
content_tag(:th, 'Univariate', colspan: '2') +
|
43
|
+
content_tag(:th, 'Bivariate', colspan: ds_names.length)
|
44
|
+
end +
|
45
|
+
# render uni-/bi-variate analysis column headers (with reversed data_series names)
|
46
|
+
content_tag(:tr) do
|
47
|
+
content_tag(
|
48
|
+
:td,
|
49
|
+
link_to(
|
50
|
+
'All Univariates ⬇',
|
51
|
+
url_for(
|
52
|
+
rde: {
|
53
|
+
univariate: ds_names.each_with_index.inject({}) { |m, (e, idx)|
|
54
|
+
m[idx] = [e]
|
55
|
+
m
|
56
|
+
}
|
57
|
+
},
|
58
|
+
anchor: 'rails_data_explorer-toc',
|
59
|
+
),
|
60
|
+
class: 'btn btn-default btn-xs'
|
61
|
+
),
|
62
|
+
colspan: 2
|
63
|
+
) +
|
64
|
+
reversed_ds_names.map { |ds_name|
|
65
|
+
content_tag(:th, ds_name, class: 'rde_toc-col_header')
|
66
|
+
}.join.html_safe
|
67
|
+
end +
|
68
|
+
# iterate over data_series
|
69
|
+
ds_names.map { |ds_name|
|
70
|
+
content_tag(:tr) do
|
71
|
+
uv_expl = explorations.detect { |e|
|
72
|
+
e.dom_id == RailsDataExplorer::Exploration.compute_dom_id(
|
73
|
+
[ds_name]
|
74
|
+
)
|
75
|
+
}
|
76
|
+
encountered_bv_with_self = false
|
77
|
+
# cell with name
|
78
|
+
content_tag(
|
79
|
+
:th,
|
80
|
+
ds_name.truncate(12),
|
81
|
+
class: 'rde_toc-row_header',
|
82
|
+
title: ds_name
|
83
|
+
) +
|
84
|
+
# cell with link to univariate analysis
|
85
|
+
if uv_expl
|
86
|
+
if uv_expl.render_charts?
|
87
|
+
# Link to anchor on current page (chart is currently rendered)
|
88
|
+
content_tag(
|
89
|
+
:td,
|
90
|
+
link_to(
|
91
|
+
'⬅',
|
92
|
+
"##{ uv_expl.dom_id }",
|
93
|
+
class: 'btn btn-default btn-xs'
|
94
|
+
),
|
95
|
+
class: 'rde_toc-currently_rendered',
|
96
|
+
)
|
97
|
+
else
|
98
|
+
# Load new page
|
99
|
+
content_tag(
|
100
|
+
:td,
|
101
|
+
link_to(
|
102
|
+
'⬅',
|
103
|
+
url_for(
|
104
|
+
rde: { univariate: { '1' => uv_expl.data_series_names }},
|
105
|
+
anchor: uv_expl.dom_id
|
106
|
+
),
|
107
|
+
class: 'btn btn-default btn-xs'
|
108
|
+
),
|
109
|
+
class: 'rde_toc-available_not_rendered'
|
110
|
+
)
|
111
|
+
end
|
112
|
+
else
|
113
|
+
# show that no exploration exists
|
114
|
+
content_tag(:td, 'N/A', class: 'rde_toc-not_available')
|
115
|
+
end +
|
116
|
+
# iterate over reversed data_series names
|
117
|
+
reversed_ds_names.map { |r_ds_name|
|
118
|
+
bv_expl = explorations.detect { |e|
|
119
|
+
e.dom_id == RailsDataExplorer::Exploration.compute_dom_id(
|
120
|
+
[ds_name, r_ds_name]
|
121
|
+
)
|
122
|
+
}
|
123
|
+
if encountered_bv_with_self
|
124
|
+
# blank cell
|
125
|
+
'<td class="rde_toc-oso_diagonal"></td>'.html_safe
|
126
|
+
elsif ds_name == r_ds_name
|
127
|
+
# intersection with self
|
128
|
+
encountered_bv_with_self = true
|
129
|
+
params_counter = '0'
|
130
|
+
# Link to anchor on new page (chart is currently not rendered)
|
131
|
+
content_tag(
|
132
|
+
:td,
|
133
|
+
link_to(
|
134
|
+
image_tag('rails-data-explorer/multiple_bivariate_small.png'),
|
135
|
+
url_for(
|
136
|
+
rde: {
|
137
|
+
univariate: { '1' => [r_ds_name] },
|
138
|
+
bivariate: ds_names.each_with_object({}) { |e,m|
|
139
|
+
next if r_ds_name == e # skip bivariate with self
|
140
|
+
m[params_counter.succ!] = [r_ds_name, e]
|
141
|
+
}
|
142
|
+
},
|
143
|
+
anchor: 'rails_data_explorer-toc',
|
144
|
+
),
|
145
|
+
class: 'btn btn-default btn-xs'
|
146
|
+
),
|
147
|
+
class: 'rde_toc-available_not_rendered'
|
148
|
+
)
|
149
|
+
elsif bv_expl
|
150
|
+
# bivariate analysis exists
|
151
|
+
if bv_expl.render_charts?
|
152
|
+
# Link to anchor on current page (chart is currently rendered)
|
153
|
+
content_tag(
|
154
|
+
:td,
|
155
|
+
link_to(
|
156
|
+
'X',
|
157
|
+
"##{ bv_expl.dom_id }",
|
158
|
+
class: 'btn btn-default btn-xs'
|
159
|
+
),
|
160
|
+
class: 'rde_toc-currently_rendered',
|
161
|
+
)
|
162
|
+
else
|
163
|
+
# Link to anchor on new page (chart is currently not rendered)
|
164
|
+
content_tag(
|
165
|
+
:td,
|
166
|
+
link_to(
|
167
|
+
'X',
|
168
|
+
url_for(
|
169
|
+
rde: { bivariate: { '1' => bv_expl.data_series_names }},
|
170
|
+
anchor: bv_expl.dom_id
|
171
|
+
),
|
172
|
+
class: 'btn btn-default btn-xs'
|
173
|
+
),
|
174
|
+
class: 'rde_toc-available_not_rendered'
|
175
|
+
)
|
176
|
+
end
|
177
|
+
else
|
178
|
+
# show that no exploration exists
|
179
|
+
content_tag(:td, 'N/A', class: 'rde_toc-not_available')
|
180
|
+
end
|
181
|
+
}.join.html_safe
|
182
|
+
end
|
183
|
+
}.join.html_safe
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def rde_explorations_with_charts(explorations)
|
190
|
+
explorations.map { |e| e.render }.join.html_safe
|
9
191
|
end
|
10
192
|
|
11
193
|
end
|
@@ -6,19 +6,25 @@ class RailsDataExplorer
|
|
6
6
|
# It's an engine so that we can add javascript and image assets
|
7
7
|
# to the asset pipeline.
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# end
|
9
|
+
isolate_namespace RailsDataExplorer
|
10
|
+
|
11
|
+
# ActiveSupport.on_load :action_controller do
|
12
|
+
# include RailsDataExplorer::ActionControllerExtension
|
14
13
|
# end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
#
|
15
|
+
ActiveSupport.on_load :action_view do
|
16
|
+
include RailsDataExplorer::ActionViewExtension
|
17
|
+
end
|
18
|
+
|
19
|
+
# ActiveSupport.on_load :active_record do
|
20
|
+
# extend RailsDataExplorer::ActiveRecordExtension
|
21
21
|
# end
|
22
22
|
|
23
|
+
initializer "filterrific" do |app|
|
24
|
+
app.config.assets.precompile += %w(
|
25
|
+
multiple_bivariate_small.png
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
23
29
|
end
|
24
30
|
end
|
@@ -6,22 +6,32 @@ class RailsDataExplorer
|
|
6
6
|
|
7
7
|
attr_accessor :charts, :data_set, :title
|
8
8
|
|
9
|
+
delegate :data_series_names, to: :data_set, prefix: false
|
9
10
|
delegate :number_of_values, to: :data_set, prefix: false
|
10
11
|
|
12
|
+
# Computes a dom_id for data_series_names
|
13
|
+
# @param data_series_names [Array<String>]
|
14
|
+
# @return [String]
|
15
|
+
def self.compute_dom_id(data_series_names)
|
16
|
+
"rde-exploration-#{ data_series_names.sort.map { |e| e.parameterize('') }.join('-') }"
|
17
|
+
end
|
18
|
+
|
11
19
|
# Initializes a new visualization.
|
12
|
-
# @param[String]
|
13
|
-
# @param[Array]
|
20
|
+
# @param _title [String] will be printed at top of visualization
|
21
|
+
# @param data_set_or_array [Array] can be a number of things:
|
14
22
|
# * Array<Scalar> - for single data series, uni-variate options are applied.
|
15
23
|
# * Array<Hash> - for multiple data series, bi/multi-variate options are applied.
|
16
24
|
# * DataSet - For finer grained control.
|
17
|
-
# @param[
|
25
|
+
# @param render_charts [Boolean] set to true to render charts for this exploration
|
26
|
+
# @param chart_specs [Array<Chart, String, Symbol>, optional]
|
18
27
|
# The list of charts to include. Defaults to all applicable charts for the
|
19
28
|
# given data_set_or_array.
|
20
29
|
# Charts can be provided as Array of Strings, Symbols, or Chart classes
|
21
30
|
# (can be mixed).
|
22
|
-
def initialize(_title, data_set_or_array, chart_specs=nil)
|
31
|
+
def initialize(_title, data_set_or_array, render_charts, chart_specs=nil)
|
23
32
|
@title = _title
|
24
33
|
@data_set = initialize_data_set(data_set_or_array)
|
34
|
+
@render_charts = render_charts
|
25
35
|
@charts = initialize_charts(chart_specs)
|
26
36
|
end
|
27
37
|
|
@@ -41,8 +51,13 @@ class RailsDataExplorer
|
|
41
51
|
end.html_safe
|
42
52
|
end
|
43
53
|
|
54
|
+
# Returns true if charts for this exploration are to be rendered.
|
55
|
+
def render_charts?
|
56
|
+
@render_charts
|
57
|
+
end
|
58
|
+
|
44
59
|
def dom_id
|
45
|
-
|
60
|
+
self.class.compute_dom_id(data_series_names)
|
46
61
|
end
|
47
62
|
|
48
63
|
def inspect(indent=1, recursive=1000)
|
@@ -74,6 +89,7 @@ class RailsDataExplorer
|
|
74
89
|
|
75
90
|
def initialize_charts(chart_specs)
|
76
91
|
if chart_specs.present?
|
92
|
+
raise "Handle chart_specs: #{ chart_specs.inspect }"
|
77
93
|
chart_specs.map { |chart_spec|
|
78
94
|
case chart_spec
|
79
95
|
when Chart
|
@@ -94,7 +110,7 @@ class RailsDataExplorer
|
|
94
110
|
DataSet.new(data_set_or_array, @title)
|
95
111
|
when DataSet
|
96
112
|
# use as is
|
97
|
-
|
113
|
+
data_set_or_array
|
98
114
|
else
|
99
115
|
raise(
|
100
116
|
ArgumentError.new(
|
data/lib/rails_data_explorer.rb
CHANGED
@@ -4,70 +4,107 @@ class RailsDataExplorer
|
|
4
4
|
include ActionView::Helpers::TagHelper
|
5
5
|
|
6
6
|
attr_reader :explorations
|
7
|
-
|
8
|
-
|
7
|
+
attr_reader :data_series_names
|
8
|
+
|
9
|
+
# Top level initialization. This is what you normally should use.
|
10
|
+
# @param data_collection [Array<Array>] Outer array is the container, inner
|
11
|
+
# array represents each record (row of data).
|
12
|
+
# @param data_series_specs [Array<Hash>] One Hash for each data series.
|
13
|
+
# @param explorations_to_render [Hash]
|
14
|
+
# {
|
15
|
+
# "univariate" => {
|
16
|
+
# "1" => ["Hour of day"],
|
17
|
+
# },
|
18
|
+
# "bivariate" => {
|
19
|
+
# "1" => ["Context", "Release (major)"],
|
20
|
+
# "2" => ["Year", "Timezone"],
|
21
|
+
# }
|
22
|
+
# }
|
23
|
+
def initialize(data_collection, data_series_specs, explorations_to_render)
|
9
24
|
@explorations = []
|
10
|
-
|
11
|
-
|
12
|
-
|
25
|
+
charts = {
|
26
|
+
univariate: [],
|
27
|
+
bivariate: {},
|
28
|
+
multivariate: {}
|
29
|
+
}
|
30
|
+
@data_series_names = data_series_specs.map { |e| e[:name] }
|
31
|
+
# Default to all univariate explorations
|
32
|
+
explorations_to_render = (
|
33
|
+
explorations_to_render || @data_series_names.inject({ univariate: {}}) { |m,e|
|
34
|
+
m[:univariate][e] = [e]
|
35
|
+
m
|
36
|
+
}
|
37
|
+
).symbolize_keys
|
13
38
|
|
39
|
+
# Build list of all available explorations (rendered and not rendered),
|
40
|
+
# grouped by type_of_analysis
|
14
41
|
data_series_specs.each do |data_series_spec|
|
15
|
-
ds_spec = {
|
16
|
-
univariate: true,
|
17
|
-
bivariate: true,
|
18
|
-
}.merge(data_series_spec)
|
19
|
-
univariate << ds_spec.dup if ds_spec[:univariate]
|
20
|
-
|
21
|
-
if ds_spec[:bivariate]
|
22
|
-
[*ds_spec[:bivariate]].each { |group_key|
|
23
|
-
group_key = group_key.to_s
|
24
|
-
bivariate[group_key] ||= []
|
25
|
-
bivariate[group_key] << ds_spec.dup
|
26
|
-
}
|
27
|
-
end
|
28
42
|
|
29
|
-
|
30
|
-
|
43
|
+
charts[:univariate] << data_series_spec.dup
|
44
|
+
|
45
|
+
charts[:bivariate]['rde-default'] ||= []
|
46
|
+
charts[:bivariate]['rde-default'] << data_series_spec.dup
|
47
|
+
|
48
|
+
# No defaults for multivariate yet... Have to be specified manually via
|
49
|
+
# data_series specs
|
50
|
+
if data_series_spec[:multivariate]
|
51
|
+
[*data_series_spec[:multivariate]].each { |group_key|
|
31
52
|
group_key = group_key.to_s
|
32
|
-
multivariate[group_key] ||= []
|
33
|
-
multivariate[group_key] <<
|
53
|
+
charts[:multivariate][group_key] ||= []
|
54
|
+
charts[:multivariate][group_key] << data_series_spec.dup
|
34
55
|
}
|
35
56
|
end
|
57
|
+
|
36
58
|
end
|
37
59
|
|
38
|
-
univariate.uniq.compact.each { |data_series_spec|
|
60
|
+
charts[:univariate].uniq.compact.each { |data_series_spec|
|
39
61
|
@explorations << Exploration.new(
|
40
62
|
data_series_spec[:name],
|
41
63
|
data_collection.map(&data_series_spec[:data_method]),
|
64
|
+
render_exploration_for?(
|
65
|
+
explorations_to_render,
|
66
|
+
:univariate,
|
67
|
+
[data_series_spec[:name]]
|
68
|
+
)
|
42
69
|
)
|
43
70
|
}
|
44
71
|
|
45
|
-
bivariate.each { |group_key, bv_data_series_specs|
|
72
|
+
charts[:bivariate].each { |group_key, bv_data_series_specs|
|
46
73
|
next unless group_key # skip if key is falsey
|
47
74
|
bv_data_series_specs.uniq.compact.combination(2) { |ds_specs_pair|
|
48
75
|
@explorations << build_exploration_from_data_series_specs(
|
49
76
|
data_collection,
|
50
|
-
ds_specs_pair
|
77
|
+
ds_specs_pair,
|
78
|
+
render_exploration_for?(
|
79
|
+
explorations_to_render,
|
80
|
+
:bivariate,
|
81
|
+
ds_specs_pair.map { |e| e[:name] }
|
82
|
+
)
|
51
83
|
)
|
52
84
|
}
|
53
85
|
}
|
54
86
|
|
55
|
-
multivariate.each { |group_key, mv_data_series_specs|
|
87
|
+
charts[:multivariate].each { |group_key, mv_data_series_specs|
|
56
88
|
next unless group_key # skip key `false` or `nil`
|
57
89
|
ds_specs = mv_data_series_specs.uniq.compact
|
58
90
|
@explorations << build_exploration_from_data_series_specs(
|
59
91
|
data_collection,
|
60
|
-
ds_specs
|
92
|
+
ds_specs,
|
93
|
+
true # always render multivariate since they are specified manually
|
61
94
|
)
|
62
95
|
}
|
63
96
|
end
|
64
97
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
98
|
+
def explorations_with_charts_available
|
99
|
+
explorations.find_all { |e| e.charts.any? }
|
100
|
+
end
|
101
|
+
|
102
|
+
def explorations_with_charts_to_render
|
103
|
+
explorations_with_charts_available.find_all { |e| e.render_charts? }
|
104
|
+
end
|
105
|
+
|
106
|
+
def explorations_with_no_charts_available
|
107
|
+
explorations.find_all { |e| e.charts.empty? }
|
71
108
|
end
|
72
109
|
|
73
110
|
def number_of_values
|
@@ -76,7 +113,7 @@ class RailsDataExplorer
|
|
76
113
|
|
77
114
|
private
|
78
115
|
|
79
|
-
def build_exploration_from_data_series_specs(data_collection, ds_specs)
|
116
|
+
def build_exploration_from_data_series_specs(data_collection, ds_specs, render_charts)
|
80
117
|
Exploration.new(
|
81
118
|
ds_specs.map { |e| e[:name] }.sort.join(' vs. '),
|
82
119
|
ds_specs.map { |ds_spec|
|
@@ -84,65 +121,33 @@ private
|
|
84
121
|
name: ds_spec[:name],
|
85
122
|
values: data_collection.map(&ds_spec[:data_method])
|
86
123
|
}
|
87
|
-
}
|
124
|
+
},
|
125
|
+
render_charts
|
88
126
|
)
|
89
127
|
end
|
90
128
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
end
|
113
|
-
}.join.html_safe
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def render_charts(expls)
|
121
|
-
expls.map { |e| e.render }.join.html_safe
|
122
|
-
end
|
123
|
-
|
124
|
-
def render_explorations_without_charts(expls)
|
125
|
-
return '' if expls.empty?
|
126
|
-
content_tag(:div, class: 'rde panel panel-default') do
|
127
|
-
content_tag(:div, class: 'panel-heading') do
|
128
|
-
content_tag(:h2, "Explorations without charts", class: 'rde-exploration-title panel-title')
|
129
|
-
end +
|
130
|
-
content_tag(:div, class: 'panel-body') do
|
131
|
-
content_tag(:p, "There are no charts available for the following explorations:") +
|
132
|
-
content_tag(:ul) do
|
133
|
-
expls.map { |expl|
|
134
|
-
content_tag(:li, expl.title).html_safe
|
135
|
-
}.join.html_safe
|
136
|
-
end
|
137
|
-
end
|
129
|
+
# Returns true if data_series with data_series_names should have charts for
|
130
|
+
# explorations with type_of_analysis rendered.
|
131
|
+
# @param explorations_to_render [Hash]
|
132
|
+
# {:bivariate=>{"rde-exploration-context-year"=>["Context", "Year"]}}
|
133
|
+
# @param type_of_analysis [Symbol] one of :univariate, :bivariate, :multivariate
|
134
|
+
# @param data_series_names [Array<String>] names of data_series to return answer for
|
135
|
+
# @return [Boolean]
|
136
|
+
def render_exploration_for?(explorations_to_render, type_of_analysis, data_series_names)
|
137
|
+
case type_of_analysis
|
138
|
+
when :univariate
|
139
|
+
# Return true if a :univariate exploration exists that contains data_series_names
|
140
|
+
(explorations_to_render[:univariate] || []).any? { |dom_id, ds_names|
|
141
|
+
data_series_names.sort == ds_names.sort
|
142
|
+
}
|
143
|
+
when :bivariate
|
144
|
+
# Return true if a :bivariate exploration exists that contains data_series_names
|
145
|
+
(explorations_to_render[:bivariate] || []).any? { |dom_id, ds_names|
|
146
|
+
data_series_names.sort == ds_names.sort
|
147
|
+
}
|
148
|
+
else
|
149
|
+
raise "Handle this type_of_analysis: #{ type_of_analysis.inspect }"
|
138
150
|
end
|
139
151
|
end
|
140
152
|
|
141
|
-
def separate_explorations_with_and_without_charts
|
142
|
-
explorations.inject({ with: [], without: [] }) { |m, e|
|
143
|
-
m[e.charts.any? ? :with : :without] << e
|
144
|
-
m
|
145
|
-
}
|
146
|
-
end
|
147
|
-
|
148
153
|
end
|
data/rails-data-explorer.gemspec
CHANGED
@@ -40,3 +40,35 @@ td.rde-numerical {
|
|
40
40
|
line-height: normal;
|
41
41
|
text-align: right;
|
42
42
|
}
|
43
|
+
|
44
|
+
table.rde_toc-matrix.table td {
|
45
|
+
text-align: center;
|
46
|
+
vertical-align: middle;
|
47
|
+
}
|
48
|
+
|
49
|
+
table.rde_toc-matrix.table th {
|
50
|
+
font-weight: normal;
|
51
|
+
}
|
52
|
+
|
53
|
+
th.rde_toc-row_header {
|
54
|
+
white-space: nowrap;
|
55
|
+
overflow-x: hidden;
|
56
|
+
}
|
57
|
+
|
58
|
+
th.rde_toc-col_header {
|
59
|
+
text-align: center;
|
60
|
+
}
|
61
|
+
|
62
|
+
td.rde_toc-available_not_rendered {
|
63
|
+
}
|
64
|
+
|
65
|
+
td.rde_toc-currently_rendered {
|
66
|
+
background-color: #cfc;
|
67
|
+
}
|
68
|
+
|
69
|
+
td.rde_toc-not_available {
|
70
|
+
color: #999;
|
71
|
+
}
|
72
|
+
|
73
|
+
td.rde_toc-oso_diagonal {
|
74
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-data-explorer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Hund
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: color
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- MIT-LICENSE
|
164
164
|
- README.md
|
165
165
|
- Rakefile
|
166
|
+
- app/assets/images/rails-data-explorer/multiple_bivariate_small.png
|
166
167
|
- doc/how_to/release.md
|
167
168
|
- doc/how_to/trouble_when_packaging_assets.md
|
168
169
|
- doc/rails-data-explorer-screenshot.png
|