rails-data-explorer 0.2.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -3
- data/README.md +2 -0
- data/lib/rails-data-explorer-no-rails.rb +36 -32
- data/lib/rails-data-explorer.rb +38 -35
- data/lib/rails_data_explorer.rb +29 -10
- data/lib/{rails-data-explorer → rails_data_explorer}/action_view_extension.rb +39 -17
- data/lib/rails_data_explorer/active_record_extension.rb +19 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/chart.rb +10 -0
- data/lib/rails_data_explorer/chart/anova.rb +1 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/box_plot.rb +12 -3
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/box_plot_group.rb +49 -22
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/contingency_table.rb +19 -8
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/descriptive_statistics_table.rb +9 -0
- data/lib/rails_data_explorer/chart/descriptive_statistics_table_group.rb +1 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/histogram_categorical.rb +12 -8
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/histogram_quantitative.rb +12 -2
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/histogram_temporal.rb +11 -2
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/multi_dimensional_charts.rb +2 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/parallel_coordinates.rb +11 -1
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/parallel_set.rb +11 -2
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/pie_chart.rb +12 -8
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/scatterplot.rb +13 -1
- data/lib/{rails-data-explorer → rails_data_explorer}/chart/scatterplot_matrix.rb +2 -0
- data/lib/{rails-data-explorer/chart/stacked_bar_chart_categorical_percent.rb → rails_data_explorer/chart/stacked_bar_chart_categorical.rb} +37 -14
- data/lib/rails_data_explorer/chart/stacked_bar_chart_categorical_percent.rb +28 -0
- data/lib/rails_data_explorer/chart/stacked_histogram_temporal.rb +199 -0
- data/lib/rails_data_explorer/data_series.rb +241 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_set.rb +13 -4
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type.rb +13 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/categorical.rb +79 -18
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/geo.rb +2 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/quantitative.rb +14 -4
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/quantitative/decimal.rb +9 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/quantitative/integer.rb +9 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/data_type/quantitative/temporal.rb +9 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/engine.rb +12 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/exploration.rb +11 -0
- data/lib/rails_data_explorer/statistics/pearsons_chi_squared_independence_test.rb +72 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/statistics/rng_category.rb +13 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/statistics/rng_gaussian.rb +12 -1
- data/lib/{rails-data-explorer → rails_data_explorer}/statistics/rng_power_law.rb +11 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/color_scale.rb +6 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/data_binner.rb +13 -8
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/data_encoder.rb +2 -0
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/data_quantizer.rb +8 -3
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/rde_table.rb +14 -11
- data/lib/{rails-data-explorer → rails_data_explorer}/utils/value_formatter.rb +9 -4
- data/rails-data-explorer.gemspec +5 -6
- data/spec/rails_data_explorer/chart_spec.rb +11 -0
- data/spec/{rails-data-explorer → rails_data_explorer}/data_series_spec.rb +0 -0
- data/spec/rails_data_explorer/data_set_spec.rb +31 -0
- data/spec/rails_data_explorer/data_type/categorical_spec.rb +126 -0
- data/{lib/rails-data-explorer/chart/descriptive_statistics_table_group.rb → spec/rails_data_explorer/data_type/quantitative/decimal_spec.rb} +0 -0
- data/spec/rails_data_explorer/data_type/quantitative/integer_spec.rb +0 -0
- data/spec/rails_data_explorer/data_type/quantitative/temporal_spec.rb +34 -0
- data/spec/rails_data_explorer/data_type/quantitative_spec.rb +118 -0
- data/spec/rails_data_explorer/data_type_spec.rb +7 -0
- data/spec/{rails-data-explorer → rails_data_explorer}/exploration_spec.rb +5 -5
- data/spec/rails_data_explorer/statistics/pearsons_chi_squared_independence_test_spec.rb +0 -0
- data/spec/rails_data_explorer/utils/color_scale_spec.rb +13 -0
- data/spec/{rails-data-explorer → rails_data_explorer}/utils/data_binner_spec.rb +0 -0
- data/spec/{rails-data-explorer → rails_data_explorer}/utils/data_quantizer_spec.rb +0 -0
- data/spec/rails_data_explorer/utils/value_formatter_spec.rb +33 -0
- data/vendor/assets/stylesheets/sources/rde-default-style.css +5 -1
- metadata +91 -82
- data/lib/rails-data-explorer/active_record_extension.rb +0 -14
- data/lib/rails-data-explorer/constants.rb +0 -5
- data/lib/rails-data-explorer/data_series.rb +0 -156
- data/lib/rails-data-explorer/statistics/pearsons_chi_squared_independence_test.rb +0 -75
- data/spec/rails-data-explorer/data_type/categorical_spec.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 411afabc4250e907fbdbe7e70805be898219eb5a
|
4
|
+
data.tar.gz: 6a95cd6abc7828634bfd88ac69ca9b2a805a4970
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 598df5a92a7f39dbb213283cfd93cbf0a7c72fdc3c12aaa03fd875d924b2160eacfcdbec079045c8a8eca67da6fa336939ed58e8f4d8b6e839ce48ba5ad866d9
|
7
|
+
data.tar.gz: 8f9ee3dd2de65400978ea82a3445c40974bac8e5a5e8a54137fe062a25eed16ecd6b10e92e5a2ffcdf57b7ad37f651451b12f6e4d23a5b93271630f9f7a1226e
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
TODO: add sampling for large ActiveRecord tables
|
2
|
+
|
3
|
+
# 1.0.0
|
4
|
+
|
5
|
+
* New chart type: StackedBarChartCategorical to go with its percentage cousing.
|
6
|
+
* Improved display of table of contents.
|
7
|
+
* Improved display of box plot groups: Auto scale charts to make best use of
|
8
|
+
screen space when there are extreme outliers.
|
9
|
+
* Automatically limit the number of distinct values in a categorical data series
|
10
|
+
to reduce number of items in categorical charts. Group less frequent observations
|
11
|
+
under '[Other]'.
|
12
|
+
* Made charts wider to use more screen space.
|
13
|
+
* Scroll contingency tables horizontally if they are too wide.
|
14
|
+
* Improved label sorter for categorical values. When working with a mix of
|
15
|
+
numeric and non-numeric labels, sort non-numeric ones at the end.
|
16
|
+
* Improved performance by caching a lot of computed data.
|
17
|
+
* Removed obsolete files.
|
18
|
+
* Improved documentation.
|
19
|
+
* Various bug fixes.
|
4
20
|
|
5
21
|
### 0.2.3
|
6
22
|
|
data/README.md
CHANGED
@@ -27,7 +27,9 @@ named 'signups' in `app/controllers/users_controller.rb`:
|
|
27
27
|
|
28
28
|
~~~ ruby
|
29
29
|
def signups
|
30
|
+
# DANGER! Make sure not to load too much data into memory!
|
30
31
|
user_data = User.all.to_a
|
32
|
+
|
31
33
|
c_binner = RailsDataExplorer::Utils::DataBinner.new(
|
32
34
|
'0' => 0,
|
33
35
|
'1' => 1,
|
@@ -7,37 +7,41 @@ require 'descriptive-statistics'
|
|
7
7
|
require 'distribution'
|
8
8
|
require 'interpolate'
|
9
9
|
|
10
|
-
# require '
|
10
|
+
# require 'rails_data_explorer/action_view_extension.rb'
|
11
11
|
|
12
|
-
require 'rails_data_explorer'
|
13
|
-
require 'rails-data-explorer/chart'
|
14
|
-
require 'rails-data-explorer/constants'
|
15
|
-
require 'rails-data-explorer/data_series'
|
16
|
-
require 'rails-data-explorer/data_set'
|
17
|
-
require 'rails-data-explorer/data_type'
|
18
|
-
require 'rails-data-explorer/exploration'
|
19
|
-
require 'rails-data-explorer/statistics/rng_category'
|
20
|
-
require 'rails-data-explorer/statistics/rng_gaussian'
|
21
|
-
require 'rails-data-explorer/statistics/rng_power_law'
|
22
|
-
require 'rails-data-explorer/utils/color_scale'
|
23
|
-
require 'rails-data-explorer/utils/data_binner'
|
24
|
-
require 'rails-data-explorer/utils/data_quantizer'
|
25
|
-
require 'rails-data-explorer/utils/value_formatter'
|
12
|
+
# require 'rails_data_explorer/engine.rb'
|
26
13
|
|
27
|
-
require '
|
28
|
-
require '
|
29
|
-
require '
|
30
|
-
require '
|
31
|
-
require '
|
32
|
-
require '
|
33
|
-
require '
|
34
|
-
require '
|
35
|
-
require '
|
36
|
-
require '
|
37
|
-
require '
|
38
|
-
require '
|
39
|
-
require '
|
40
|
-
require '
|
41
|
-
|
42
|
-
require '
|
43
|
-
require '
|
14
|
+
require 'rails_data_explorer.rb'
|
15
|
+
require 'rails_data_explorer/chart.rb'
|
16
|
+
require 'rails_data_explorer/data_series.rb'
|
17
|
+
require 'rails_data_explorer/data_set.rb'
|
18
|
+
require 'rails_data_explorer/data_type.rb'
|
19
|
+
require 'rails_data_explorer/exploration.rb'
|
20
|
+
require 'rails_data_explorer/statistics/rng_category.rb'
|
21
|
+
require 'rails_data_explorer/statistics/rng_gaussian.rb'
|
22
|
+
require 'rails_data_explorer/statistics/rng_power_law.rb'
|
23
|
+
require 'rails_data_explorer/utils/color_scale.rb'
|
24
|
+
require 'rails_data_explorer/utils/data_binner.rb'
|
25
|
+
require 'rails_data_explorer/utils/data_quantizer.rb'
|
26
|
+
require 'rails_data_explorer/utils/rde_table.rb'
|
27
|
+
require 'rails_data_explorer/utils/value_formatter.rb'
|
28
|
+
|
29
|
+
require 'rails_data_explorer/chart/box_plot.rb'
|
30
|
+
require 'rails_data_explorer/chart/box_plot_group.rb'
|
31
|
+
require 'rails_data_explorer/chart/contingency_table.rb'
|
32
|
+
require 'rails_data_explorer/chart/descriptive_statistics_table.rb'
|
33
|
+
require 'rails_data_explorer/chart/histogram_categorical.rb'
|
34
|
+
require 'rails_data_explorer/chart/histogram_quantitative.rb'
|
35
|
+
require 'rails_data_explorer/chart/histogram_temporal.rb'
|
36
|
+
require 'rails_data_explorer/chart/parallel_coordinates.rb'
|
37
|
+
require 'rails_data_explorer/chart/parallel_set.rb'
|
38
|
+
require 'rails_data_explorer/chart/pie_chart.rb'
|
39
|
+
require 'rails_data_explorer/chart/scatterplot.rb'
|
40
|
+
require 'rails_data_explorer/chart/stacked_bar_chart_categorical.rb'
|
41
|
+
require 'rails_data_explorer/data_type/categorical.rb'
|
42
|
+
require 'rails_data_explorer/data_type/quantitative.rb'
|
43
|
+
require 'rails_data_explorer/data_type/quantitative/decimal.rb'
|
44
|
+
require 'rails_data_explorer/data_type/quantitative/integer.rb'
|
45
|
+
require 'rails_data_explorer/data_type/quantitative/temporal.rb'
|
46
|
+
|
47
|
+
require 'rails_data_explorer/chart/stacked_bar_chart_categorical_percent.rb'
|
data/lib/rails-data-explorer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
require 'action_view'
|
2
4
|
require 'active_support/all' # TODO: once the dust settles, only require the modules we need
|
3
5
|
require 'color'
|
@@ -5,41 +7,42 @@ require 'descriptive-statistics'
|
|
5
7
|
require 'distribution'
|
6
8
|
require 'interpolate'
|
7
9
|
|
8
|
-
require '
|
10
|
+
require 'rails_data_explorer/action_view_extension.rb'
|
11
|
+
|
12
|
+
require 'rails_data_explorer/engine.rb'
|
9
13
|
|
10
|
-
require '
|
14
|
+
require 'rails_data_explorer.rb'
|
15
|
+
require 'rails_data_explorer/chart.rb'
|
16
|
+
require 'rails_data_explorer/data_series.rb'
|
17
|
+
require 'rails_data_explorer/data_set.rb'
|
18
|
+
require 'rails_data_explorer/data_type.rb'
|
19
|
+
require 'rails_data_explorer/exploration.rb'
|
20
|
+
require 'rails_data_explorer/statistics/rng_category.rb'
|
21
|
+
require 'rails_data_explorer/statistics/rng_gaussian.rb'
|
22
|
+
require 'rails_data_explorer/statistics/rng_power_law.rb'
|
23
|
+
require 'rails_data_explorer/utils/color_scale.rb'
|
24
|
+
require 'rails_data_explorer/utils/data_binner.rb'
|
25
|
+
require 'rails_data_explorer/utils/data_quantizer.rb'
|
26
|
+
require 'rails_data_explorer/utils/rde_table.rb'
|
27
|
+
require 'rails_data_explorer/utils/value_formatter.rb'
|
11
28
|
|
12
|
-
require 'rails_data_explorer'
|
13
|
-
require '
|
14
|
-
require '
|
15
|
-
require '
|
16
|
-
require '
|
17
|
-
require '
|
18
|
-
require '
|
19
|
-
require '
|
20
|
-
require '
|
21
|
-
require '
|
22
|
-
require '
|
23
|
-
require '
|
24
|
-
require '
|
25
|
-
require '
|
26
|
-
require '
|
29
|
+
require 'rails_data_explorer/chart/box_plot.rb'
|
30
|
+
require 'rails_data_explorer/chart/box_plot_group.rb'
|
31
|
+
require 'rails_data_explorer/chart/contingency_table.rb'
|
32
|
+
require 'rails_data_explorer/chart/descriptive_statistics_table.rb'
|
33
|
+
require 'rails_data_explorer/chart/histogram_categorical.rb'
|
34
|
+
require 'rails_data_explorer/chart/histogram_quantitative.rb'
|
35
|
+
require 'rails_data_explorer/chart/histogram_temporal.rb'
|
36
|
+
require 'rails_data_explorer/chart/parallel_coordinates.rb'
|
37
|
+
require 'rails_data_explorer/chart/parallel_set.rb'
|
38
|
+
require 'rails_data_explorer/chart/pie_chart.rb'
|
39
|
+
require 'rails_data_explorer/chart/scatterplot.rb'
|
40
|
+
require 'rails_data_explorer/chart/stacked_bar_chart_categorical.rb'
|
41
|
+
# require 'rails_data_explorer/chart/stacked_histogram_temporal.rb'
|
42
|
+
require 'rails_data_explorer/data_type/categorical.rb'
|
43
|
+
require 'rails_data_explorer/data_type/quantitative.rb'
|
44
|
+
require 'rails_data_explorer/data_type/quantitative/decimal.rb'
|
45
|
+
require 'rails_data_explorer/data_type/quantitative/integer.rb'
|
46
|
+
require 'rails_data_explorer/data_type/quantitative/temporal.rb'
|
27
47
|
|
28
|
-
require '
|
29
|
-
require 'rails-data-explorer/chart/box_plot_group'
|
30
|
-
require 'rails-data-explorer/chart/contingency_table'
|
31
|
-
require 'rails-data-explorer/chart/descriptive_statistics_table'
|
32
|
-
require 'rails-data-explorer/chart/histogram_categorical'
|
33
|
-
require 'rails-data-explorer/chart/histogram_quantitative'
|
34
|
-
require 'rails-data-explorer/chart/histogram_temporal'
|
35
|
-
require 'rails-data-explorer/chart/parallel_coordinates'
|
36
|
-
require 'rails-data-explorer/chart/parallel_set'
|
37
|
-
require 'rails-data-explorer/chart/pie_chart'
|
38
|
-
require 'rails-data-explorer/chart/scatterplot'
|
39
|
-
require 'rails-data-explorer/chart/stacked_bar_chart_categorical_percent'
|
40
|
-
# require 'rails-data-explorer/chart/stacked_histogram_temporal'
|
41
|
-
require 'rails-data-explorer/data_type/categorical'
|
42
|
-
require 'rails-data-explorer/data_type/quantitative'
|
43
|
-
require 'rails-data-explorer/data_type/quantitative/decimal'
|
44
|
-
require 'rails-data-explorer/data_type/quantitative/integer'
|
45
|
-
require 'rails-data-explorer/data_type/quantitative/temporal'
|
48
|
+
require 'rails_data_explorer/chart/stacked_bar_chart_categorical_percent.rb'
|
data/lib/rails_data_explorer.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Responsibilities:
|
4
|
+
# * Integrate all the pieces required for this gem
|
5
|
+
# * Initialize a collection of Explorations
|
6
|
+
#
|
7
|
+
# Collaborators:
|
8
|
+
# * Exploration
|
1
9
|
class RailsDataExplorer
|
2
10
|
|
3
|
-
|
4
|
-
include ActionView::Helpers::TagHelper
|
11
|
+
GREATER_ZERO = 1.0 / 1_000_000 # The smallest value to use if we have to avoid zero (div by zero)
|
5
12
|
|
6
13
|
attr_reader :explorations
|
7
14
|
attr_reader :data_series_names
|
@@ -28,6 +35,16 @@ class RailsDataExplorer
|
|
28
35
|
multivariate: {}
|
29
36
|
}
|
30
37
|
@data_series_names = data_series_specs.map { |e| e[:name] }
|
38
|
+
|
39
|
+
@cached_data_series = data_series_specs.inject({}) { |m, ds_spec|
|
40
|
+
m[ds_spec[:name]] = DataSeries.new(
|
41
|
+
ds_spec[:name],
|
42
|
+
data_collection.map(&ds_spec[:data_method]),
|
43
|
+
ds_spec
|
44
|
+
)
|
45
|
+
m
|
46
|
+
}
|
47
|
+
|
31
48
|
# Default to all univariate explorations
|
32
49
|
explorations_to_render = (
|
33
50
|
explorations_to_render || @data_series_names.inject({ univariate: {}}) { |m,e|
|
@@ -60,7 +77,10 @@ class RailsDataExplorer
|
|
60
77
|
charts[:univariate].uniq.compact.each { |data_series_spec|
|
61
78
|
@explorations << Exploration.new(
|
62
79
|
data_series_spec[:name],
|
63
|
-
|
80
|
+
DataSet.new(
|
81
|
+
[@cached_data_series[data_series_spec[:name]]],
|
82
|
+
data_series_spec[:name]
|
83
|
+
),
|
64
84
|
render_exploration_for?(
|
65
85
|
explorations_to_render,
|
66
86
|
:univariate,
|
@@ -114,14 +134,13 @@ class RailsDataExplorer
|
|
114
134
|
private
|
115
135
|
|
116
136
|
def build_exploration_from_data_series_specs(data_collection, ds_specs, render_charts)
|
137
|
+
expl_title = ds_specs.map { |e| e[:name] }.sort.join(' vs. ')
|
117
138
|
Exploration.new(
|
118
|
-
|
119
|
-
|
120
|
-
{
|
121
|
-
|
122
|
-
|
123
|
-
}
|
124
|
-
},
|
139
|
+
expl_title,
|
140
|
+
DataSet.new(
|
141
|
+
ds_specs.map { |ds_spec| @cached_data_series[ds_spec[:name]] },
|
142
|
+
expl_title
|
143
|
+
),
|
125
144
|
render_charts
|
126
145
|
)
|
127
146
|
end
|
@@ -1,12 +1,19 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
# Adds view helpers to ActionView
|
4
|
-
#
|
2
|
+
|
5
3
|
class RailsDataExplorer
|
4
|
+
|
5
|
+
# Responsibilities:
|
6
|
+
# * Add rails-data-explorer view helpers to ActionView
|
7
|
+
# * Render rails-data-explorer generated content
|
8
|
+
#
|
9
|
+
# Collaborators:
|
10
|
+
# * RailsDataExplorer
|
11
|
+
# * Exploration
|
12
|
+
#
|
6
13
|
module ActionViewExtension
|
7
14
|
|
8
15
|
# Renders the entire RailsDataExplorer view
|
9
|
-
# @param
|
16
|
+
# @param rde [RailsDataExplorer]
|
10
17
|
def rails_data_explorer(rde)
|
11
18
|
content_tag(:div, class: 'rails-data-explorer') do
|
12
19
|
[
|
@@ -16,7 +23,8 @@ class RailsDataExplorer
|
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|
19
|
-
# Returns a url that can be used to reset the Filterrific params
|
26
|
+
# Returns a url that can be used to reset the Filterrific params when
|
27
|
+
# rails-data-explorer is used in combination with Filterrific.
|
20
28
|
def reset_filterrific_url(opts = {})
|
21
29
|
url_for(
|
22
30
|
{ filterrific: { reset_filterrific: true } }.merge(opts)
|
@@ -37,11 +45,6 @@ class RailsDataExplorer
|
|
37
45
|
end +
|
38
46
|
content_tag(:div, class: 'panel-body') do
|
39
47
|
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
48
|
# render uni-/bi-variate analysis column headers (with reversed data_series names)
|
46
49
|
content_tag(:tr) do
|
47
50
|
content_tag(
|
@@ -57,7 +60,8 @@ class RailsDataExplorer
|
|
57
60
|
},
|
58
61
|
anchor: 'rails_data_explorer-toc',
|
59
62
|
),
|
60
|
-
class: 'btn btn-default btn-xs'
|
63
|
+
class: 'btn btn-default btn-xs',
|
64
|
+
title: 'Load univariate explorations for all data series.'
|
61
65
|
),
|
62
66
|
colspan: 2
|
63
67
|
) +
|
@@ -74,7 +78,7 @@ class RailsDataExplorer
|
|
74
78
|
)
|
75
79
|
}
|
76
80
|
encountered_bv_with_self = false
|
77
|
-
#
|
81
|
+
# row header with data_series name
|
78
82
|
content_tag(
|
79
83
|
:th,
|
80
84
|
ds_name.truncate(12),
|
@@ -83,6 +87,7 @@ class RailsDataExplorer
|
|
83
87
|
) +
|
84
88
|
# cell with link to univariate analysis
|
85
89
|
if uv_expl
|
90
|
+
tooltip_suffix = "univariate exploration for #{ ds_name.inspect }."
|
86
91
|
if uv_expl.render_charts?
|
87
92
|
# Link to anchor on current page (chart is currently rendered)
|
88
93
|
content_tag(
|
@@ -93,6 +98,7 @@ class RailsDataExplorer
|
|
93
98
|
class: 'btn btn-default btn-xs'
|
94
99
|
),
|
95
100
|
class: 'rde_toc-currently_rendered',
|
101
|
+
title: 'Jump to ' + tooltip_suffix,
|
96
102
|
)
|
97
103
|
else
|
98
104
|
# Load new page
|
@@ -106,12 +112,18 @@ class RailsDataExplorer
|
|
106
112
|
),
|
107
113
|
class: 'btn btn-default btn-xs'
|
108
114
|
),
|
109
|
-
class: 'rde_toc-available_not_rendered'
|
115
|
+
class: 'rde_toc-available_not_rendered',
|
116
|
+
title: 'Load ' + tooltip_suffix,
|
110
117
|
)
|
111
118
|
end
|
112
119
|
else
|
113
120
|
# show that no exploration exists
|
114
|
-
content_tag(
|
121
|
+
content_tag(
|
122
|
+
:td,
|
123
|
+
'N/A',
|
124
|
+
class: 'rde_toc-not_available',
|
125
|
+
title: 'There is no ' + tooltip_suffix,
|
126
|
+
)
|
115
127
|
end +
|
116
128
|
# iterate over reversed data_series names
|
117
129
|
reversed_ds_names.map { |r_ds_name|
|
@@ -120,6 +132,8 @@ class RailsDataExplorer
|
|
120
132
|
[ds_name, r_ds_name]
|
121
133
|
)
|
122
134
|
}
|
135
|
+
bv_ds_names = [ds_name.inspect, r_ds_name.inspect].sort.join(' vs. ')
|
136
|
+
tooltip_suffix = "bivariate exploration for #{ bv_ds_names }."
|
123
137
|
if encountered_bv_with_self
|
124
138
|
# blank cell
|
125
139
|
'<td class="rde_toc-oso_diagonal"></td>'.html_safe
|
@@ -144,7 +158,8 @@ class RailsDataExplorer
|
|
144
158
|
),
|
145
159
|
class: 'btn btn-default btn-xs'
|
146
160
|
),
|
147
|
-
class: 'rde_toc-available_not_rendered'
|
161
|
+
class: 'rde_toc-available_not_rendered',
|
162
|
+
title: "Load all bivariate explorations for #{ ds_name.inspect }.",
|
148
163
|
)
|
149
164
|
elsif bv_expl
|
150
165
|
# bivariate analysis exists
|
@@ -158,6 +173,7 @@ class RailsDataExplorer
|
|
158
173
|
class: 'btn btn-default btn-xs'
|
159
174
|
),
|
160
175
|
class: 'rde_toc-currently_rendered',
|
176
|
+
title: 'Jump to ' + tooltip_suffix,
|
161
177
|
)
|
162
178
|
else
|
163
179
|
# Link to anchor on new page (chart is currently not rendered)
|
@@ -171,12 +187,18 @@ class RailsDataExplorer
|
|
171
187
|
),
|
172
188
|
class: 'btn btn-default btn-xs'
|
173
189
|
),
|
174
|
-
class: 'rde_toc-available_not_rendered'
|
190
|
+
class: 'rde_toc-available_not_rendered',
|
191
|
+
title: 'Load ' + tooltip_suffix,
|
175
192
|
)
|
176
193
|
end
|
177
194
|
else
|
178
195
|
# show that no exploration exists
|
179
|
-
content_tag(
|
196
|
+
content_tag(
|
197
|
+
:td,
|
198
|
+
'N/A',
|
199
|
+
class: 'rde_toc-not_available',
|
200
|
+
title: 'There is no ' + tooltip_suffix,
|
201
|
+
)
|
180
202
|
end
|
181
203
|
}.join.html_safe
|
182
204
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
class RailsDataExplorer
|
4
|
+
|
5
|
+
# Responsibilities:
|
6
|
+
# * Add rails-data-explorer methods to ActiveRecord::Base and sub classes
|
7
|
+
#
|
8
|
+
# Collaborators:
|
9
|
+
#
|
10
|
+
module ActiveRecordExtension
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -1,4 +1,14 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
class RailsDataExplorer
|
4
|
+
|
5
|
+
# Responsibilities:
|
6
|
+
# * Visualize data
|
7
|
+
# * Integrate with front end visualization libraries
|
8
|
+
#
|
9
|
+
# Collaborators:
|
10
|
+
# * RdeTable
|
11
|
+
#
|
2
12
|
class Chart
|
3
13
|
|
4
14
|
include ActionView::Helpers::NumberHelper
|