rails-data-explorer 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d359492c5e290bf9416c9040224f2c248cb8cad9
4
- data.tar.gz: c245c7979079b276ac307427c4345fe987a303a5
3
+ metadata.gz: 20fe7f28eccad4493c4587b62d14409ead5fe178
4
+ data.tar.gz: dcadfa97805704be5521ba0ba4985de64a29d981
5
5
  SHA512:
6
- metadata.gz: e7ef42c4035f467cbf96b0bfdd6fad6725139a091fd2f3191c55042e23d3fbf0290850dae6abe6f651706f8175d0b10bf8d36d8ce9e0692e10fe2e7170ffc665
7
- data.tar.gz: 5d5e8ecdf816c24a95b10189391e75abd207454f81ed4219ad378046f7fa19c369b66ef403b6c495faf35c9f409c5b37e04ee87985e4d567a05869d604a3009c
6
+ metadata.gz: de90bf34ebed7445860e907e633d455b758addc56f9ae0e26ae47f2bb71895170ef86af84aa685312a00c1786d6e0aad26157eb2d0893a3dd2ac38cde3b84ef3
7
+ data.tar.gz: 267a938ca270d284756f5eb7b807887f3aaabdfafd74a7483c335fd31a12191485cf67d87b3b147ca1ff242ab573ac15e6d1a7af59a59f7b53df45449481ad43
@@ -3,6 +3,11 @@ TODO:
3
3
  * sampling for large ActiveRecord tables
4
4
  * automatic clustering of records (using each row as a feature vector)
5
5
 
6
+
7
+ ### 1.0.2
8
+
9
+ * Updated specs, documentation, and Gem dependencies.
10
+
6
11
  ### 1.0.1
7
12
 
8
13
  * Added :note option to data series specs
@@ -12,7 +17,7 @@ TODO:
12
17
 
13
18
  # 1.0.0
14
19
 
15
- * New chart type: StackedBarChartCategorical to go with its percentage cousing.
20
+ * New chart type: StackedBarChartCategorical to go with its percentage cousin.
16
21
  * Improved display of table of contents.
17
22
  * Improved display of box plot groups: Auto scale charts to make best use of
18
23
  screen space when there are extreme outliers.
data/README.md CHANGED
@@ -1,17 +1,97 @@
1
1
  # rails-data-explorer
2
2
 
3
- Rails-data-explorer is a Rails Engine plugin that makes it easy to explore the
4
- data in your app using charts and statistics.
3
+ rails-data-explorer (*RDE*) is a Rails engine plugin that makes it magically
4
+ easy to explore your app's data using charts and statistics.
5
5
 
6
- All you have to do is to throw your data in table form at rails-data-explorer.
7
- Rails-data-explorer then analyzes your data and automatically renders suitable
8
- charts and descriptive statistics for each column. It offers tools for uni-, bi-
9
- and multi-variate analysis. It can even find correlations in your categorical data
10
- using Pearson's Chi Squared test.
6
+ The purpose of *RDE* is to help you develop an intuition for your app's data
7
+ so that you can find patterns, correlations and anomalies in the data that
8
+ you can then further investigate and exploit.
11
9
 
12
- See below for a screenshot of what you get.
13
10
 
14
- ### Installation
11
+
12
+ ## Examples
13
+
14
+ ***
15
+
16
+ <table>
17
+ <tr>
18
+ <td>
19
+ <a href="https://raw.githubusercontent.com/jhund/rails-data-explorer/master/doc/rails-data-explorer-screenshot-all-univariate.png"><img src="https://github.com/jhund/rails-data-explorer/blob/master/doc/rails-data-explorer-screenshot-all-univariate.png" width="200" ></a>
20
+ <p>
21
+ The default charts rendered by rails-data-explorer: Univariate charts and
22
+ statistics for every column in your data.
23
+ <br/>
24
+ (Click image for full size screenshot)
25
+ </p>
26
+ </td>
27
+ <td>
28
+ <a href="https://raw.githubusercontent.com/jhund/rails-data-explorer/master/doc/rails-data-explorer-screenshot-plan-bivariate.png"><img src="https://github.com/jhund/rails-data-explorer/blob/master/doc/rails-data-explorer-screenshot-plan-bivariate.png" width="200" ></a>
29
+ <p>
30
+ All bivariate charts and statistics for the "Plan" column.
31
+ <br/>
32
+ (Click image for full size screenshot)
33
+ </p>
34
+ </td>
35
+ <tr/>
36
+ <table>
37
+
38
+ ***
39
+
40
+
41
+
42
+ ## Features
43
+
44
+ * **Optimized for simplicity and convenience**: All you have to do is provide
45
+ your data in tabular form. *RDE* then decides how to best visualize and
46
+ present your data.
47
+ * **Batteries included**: *RDE* includes everything required to render stunning
48
+ charts and visualizations. It is tightly integrated with Rails and doesn't
49
+ require knowledge of charting libraries, statistics, or data engineering.
50
+ * **Comprehensive data visualization and analysis**: Out of the box *RDE*
51
+ gives you univariate charts and statistics for each column of your data. It
52
+ also gives you single click access to all bivariate combinations
53
+ of your data columns. With a single config param, it will even generate
54
+ arbitrary multivariate charts for you.
55
+ * **Works with small- and medium-sized data**: *RDE* works great for up to ~100K records.
56
+ I'm thinking about ways to make it work for larger data series using sampling.
57
+ If you know how to do this correctly in ActiveRecord, please let me know.
58
+
59
+ Detailed features
60
+
61
+ * Integrates with ActiveRecord.
62
+ * Renders beautiful charts (using Vega/Nvd3 and d3.js).
63
+ * Uses best charting practices (using Vega visualization grammar).
64
+ * Automatically detects and handles categorical and quantitative data types.
65
+ (integer, decimal, and temporal)
66
+ * Automatically renders visualizations and statistics for univariate, bivariate
67
+ and multivariate analysis.
68
+ * Provides single click access to univarate and all possible combinations of
69
+ bivariate analyses.
70
+ * Automatically picks linear vs. logarithmic axes.
71
+ * Automatically finds top N values for categorical data to make charts easier
72
+ to read.
73
+ * Automatically sorts axis labels for maximum clarity.
74
+ * Performs Pearson's Chi squared test on bivariate analysis of categorical data.
75
+ This is super useful when analyzing and interpreting A/B test data, or to find
76
+ correlations in your data.
77
+ * Works well with the Filterrific gem for filtering data before it is fed to
78
+ *RDE*.
79
+ * Provides statistical utility methods, e.g., to bin or quantize your data.
80
+
81
+ *RDE* provides the following chart types:
82
+
83
+ * Bar chart (simple, stacked, percent distribution)
84
+ * Pie chart
85
+ * Histogram
86
+ * Box plot (single and group)
87
+ * Scatterplot
88
+ * Parallel coordinates
89
+ * Parallel set
90
+ * Contingency table with pearson's chi squared test (good to interpret A/B test data)
91
+
92
+
93
+
94
+ ## Installation
15
95
 
16
96
  `gem install rails-data-explorer`
17
97
 
@@ -20,16 +100,16 @@ or with bundler in your Gemfile:
20
100
  `gem 'rails-data-explorer'`
21
101
 
22
102
 
23
- ### Usage
24
103
 
25
- Let's say you want to explore your app's `User` signup data. Create a route and action
26
- named 'signups' in `app/controllers/users_controller.rb`:
104
+ ## Usage
105
+
106
+ Let's say you want to explore your app's `User` signup data. Create a route and
107
+ action for `users#signups`:
27
108
 
28
109
  ~~~ ruby
29
- def signups
30
- # DANGER! Make sure not to load too much data into memory!
31
- user_data = User.all.to_a
110
+ # app/controllers/users_controller.rb
32
111
 
112
+ def signups
33
113
  c_binner = RailsDataExplorer::Utils::DataBinner.new(
34
114
  '0' => 0,
35
115
  '1' => 1,
@@ -39,8 +119,8 @@ def signups
39
119
  '101..1,000' => 1000,
40
120
  '1,001..10,000' => 10000
41
121
  )
42
- @rails_data_explorer = RailsDataExplorer.new(
43
- user_data,
122
+ @rde = RailsDataExplorer.new(
123
+ User.all.to_a, # DANGER! Make sure not to load too much data into memory!
44
124
  [
45
125
  {
46
126
  name: "Session duration [Minutes]",
@@ -51,7 +131,6 @@ def signups
51
131
  {
52
132
  name: "Country",
53
133
  data_method: Proc.new { |row| row.country },
54
- multivariate: ['All'],
55
134
  },
56
135
  {
57
136
  name: "Sign in count",
@@ -60,12 +139,10 @@ def signups
60
139
  {
61
140
  name: "Language",
62
141
  data_method: Proc.new { |row| row.language },
63
- multivariate: ['All'],
64
142
  },
65
143
  {
66
144
  name: "Plan",
67
145
  data_method: Proc.new { |row| row.plan },
68
- multivariate: ['All'],
69
146
  },
70
147
  {
71
148
  name: "Sign up date",
@@ -79,7 +156,8 @@ def signups
79
156
  "#{ year } / Q#{ quarter }"
80
157
  },
81
158
  },
82
- ]
159
+ ],
160
+ params[:rde]
83
161
  )
84
162
  end
85
163
  ~~~
@@ -89,62 +167,55 @@ Then create a view at `app/views/users/signups.html.erb`:
89
167
  ~~~erb
90
168
  <div class="rails-data-explorer">
91
169
  <h1>User signup data</h1>
92
- <%= @rails_data_explorer.render %>
170
+ <%= rails_data_explorer(@rde) %>
93
171
  </div>
94
172
  ~~~
95
173
 
96
- With just a few lines of code you get comprehensive statistics and charts for your data:
174
+ With just a few lines of code you get comprehensive statistics and charts for
175
+ your data (see screenshots above).
97
176
 
98
- ***
99
-
100
- ![Rails data exploration](https://github.com/jhund/rails-data-explorer/blob/master/doc/rails-data-explorer-screenshot.png)
101
-
102
- ***
103
177
 
104
178
 
105
- ### Ways to shoot yourself in the foot
179
+ ## Ways to shoot yourself in the foot
106
180
 
107
181
  * **Loading too many DB rows at once**: Remember that you are loading ActiveRecord
108
182
  objects, and they can use a lot of ram. It's a cartesian product of number of
109
183
  rows times columns per record. As a rule of thumb, for a medium sized model with
110
- 30 columns, you can load up to 10,000 rows.
184
+ 10 columns, you can load up to ~100K rows.
111
185
  * **Using expensive operations in the `:data_method` option for a given data series**:
112
186
  As a rule of thumb, it should be ok to run simple methods that don't require
113
187
  DB access. Examples: `#.to_s`, `if` and `case`, and math operations should all
114
188
  be fine.
115
- * **Declaring too many charts**: The charts rendered are the sum of the following:
116
- * univariate: one or more charts for each data series
117
- * bivariate: the cartesian product of all data series in a bivariate group
118
- * multivariate: one or more charts for each multivariate group
119
- I have tested it with 70 charts on a single page. More are probably ok, I
120
- just haven't tested it.
121
189
  * **Drowning in detail**: rails-data-explorer makes it easy to generate a large
122
190
  number of charts. Make sure you don't miss the important data in the noise.
123
191
 
124
192
 
125
- ### Dependencies
126
193
 
127
- * ActionView >= 3.0
128
- * ActiveSupport >= 3.0
194
+ ## Dependencies
195
+
196
+ * rails >= 3.1
129
197
  * Asset pipeline (for batteries included, otherwise you'll have to pull in a number of assets manually)
130
- * jQuery
131
198
 
132
- ### Resources
133
199
 
200
+
201
+ ## Resources
202
+
203
+ * [API documentation](http://www.rubydoc.info/gems/rails-data-explorer/)
134
204
  * [Changelog](https://github.com/jhund/rails-data-explorer/blob/master/CHANGELOG.md)
135
205
  * [Source code (github)](https://github.com/jhund/rails-data-explorer)
136
206
  * [Issues](https://github.com/jhund/rails-data-explorer/issues)
137
207
  * [Rubygems.org](http://rubygems.org/gems/rails-data-explorer)
138
- * [API documentation](http://www.rubydoc.info/gems/rails-data-explorer/)
139
208
 
140
209
  [![Build Status](https://travis-ci.org/jhund/rails-data-explorer.svg?branch=master)](https://travis-ci.org/jhund/rails-data-explorer)
141
210
 
142
- ### License
211
+
212
+
213
+ ## License
143
214
 
144
215
  [MIT licensed](https://github.com/jhund/rails-data-explorer/blob/master/MIT-LICENSE).
145
216
 
146
217
 
147
218
 
148
- ### Copyright
219
+ ## Copyright
149
220
 
150
- Copyright (c) 2015 Jo Hund. See [(MIT) LICENSE](https://github.com/jhund/rails-data-explorer/blob/master/MIT-LICENSE) for details.
221
+ Copyright (c) 2014 - 2015 Jo Hund. See [(MIT) LICENSE](https://github.com/jhund/rails-data-explorer/blob/master/MIT-LICENSE) for details.
@@ -13,11 +13,31 @@ class RailsDataExplorer
13
13
  attr_reader :explorations
14
14
  attr_reader :data_series_names
15
15
 
16
- # Top level initialization. This is what you normally should use.
16
+ # Top level initialization. This is what you use to explore your data.
17
17
  # @param data_collection [Array<Array>] Outer array is the container, inner
18
18
  # array represents each record (row of data).
19
19
  # @param data_series_specs [Array<Hash>] One Hash for each data series.
20
- # @param explorations_to_render [Hash]
20
+ # @option data_series_specs [String] :name the name of the data series
21
+ # @option data_series_specs [Proc] :data_method a proc that will return the
22
+ # data for this column. Valid types are
23
+ # String, Numeric or Date/Time.
24
+ # @option data_series_specs [String] :note any comment you want to make for
25
+ # this data series. Will be printed with
26
+ # each chart that uses this data series.
27
+ # @option data_series_specs [Boolean, String] :univariate override to always
28
+ # render univariate chart and statistics for
29
+ # this data series. Defaults to true.
30
+ # @option data_series_specs [Boolean, String] :bivariate override to always
31
+ # render bivariate chart and statistics for
32
+ # this data series. Defaults to false.
33
+ # @option data_series_specs [Boolean, String] :multivariate override to always
34
+ # render multivariate chart and statistics for
35
+ # this data series. Defaults to false.
36
+ # @option data_series_specs [Integer] :max_num_distinct_values override the
37
+ # max number of distinct values for
38
+ # categorical data. Default: 20.
39
+ # @param explorations_to_render [Hash] A hash to specify which explorations
40
+ # you want rendered. Example data structure:
21
41
  # {
22
42
  # "univariate" => {
23
43
  # "1" => ["Hour of day"],
@@ -27,6 +47,7 @@ class RailsDataExplorer
27
47
  # "2" => ["Year", "Timezone"],
28
48
  # }
29
49
  # }
50
+ #
30
51
  def initialize(data_collection, data_series_specs, explorations_to_render)
31
52
  @explorations = []
32
53
  charts = {
@@ -115,18 +136,22 @@ class RailsDataExplorer
115
136
  }
116
137
  end
117
138
 
139
+ # @return [Array<Exploration>]
118
140
  def explorations_with_charts_available
119
141
  explorations.find_all { |e| e.charts.any? }
120
142
  end
121
143
 
144
+ # @return [Array<Exploration>]
122
145
  def explorations_with_charts_to_render
123
146
  explorations_with_charts_available.find_all { |e| e.render_charts? }
124
147
  end
125
148
 
149
+ # @return [Array<Exploration>]
126
150
  def explorations_with_no_charts_available
127
151
  explorations.find_all { |e| e.charts.empty? }
128
152
  end
129
153
 
154
+ # @return [Integer]
130
155
  def number_of_values
131
156
  explorations.first.number_of_values
132
157
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = 'rails-data-explorer'
6
- gem.version = '1.0.1'
6
+ gem.version = '1.0.2'
7
7
  gem.platform = Gem::Platform::RUBY
8
8
 
9
9
  gem.authors = ['Jo Hund']
@@ -26,4 +26,5 @@ Gem::Specification.new do |gem|
26
26
  gem.add_development_dependency 'minitest', '>= 0'
27
27
  gem.add_development_dependency 'minitest-spec-expect', '>= 0'
28
28
  gem.add_development_dependency 'rake', '>= 0'
29
+ gem.add_development_dependency 'yui-compressor', '>= 0'
29
30
  end
@@ -3,53 +3,64 @@ require_relative '../helper_no_rails'
3
3
  class RailsDataExplorer
4
4
  describe Exploration do
5
5
 
6
- describe "integration test" do
7
-
8
- def check_render_expectations(rendered_string, options)
9
- r = true
10
-
11
- if options[:has_charts]
12
- options[:has_charts].each { |chart_name|
13
- # TODO: use Nokogiri to test that it is a div class
14
- rendered_string.must_match(
15
- Regexp.new(Regexp.escape("rde-#{ chart_name }"))
16
- )
17
- }
18
- end
19
-
20
- r
21
- end
22
-
23
- [
24
- [
25
- ['Univariate Integer data', [1, 2, 3]],
26
- { has_charts: ['histogram-quantitative', 'descriptive-statistics-table'] }
27
- ],
28
- [
29
- ['Univariate Decimal data', [1.0, 2.0, 3.0]],
30
- { has_charts: ['histogram-quantitative', 'descriptive-statistics-table'] }
31
- ],
32
- [
33
- ['Univariate Temporal data', [DateTime.new(2015,2,7)]],
34
- { has_charts: ['histogram-temporal', 'descriptive-statistics-table'] }
35
- ],
36
- [
37
- ['Univariate Categorical data', ['a', 'b', 'c']],
38
- { has_charts: ['histogram-categorical', 'pie-chart', 'descriptive-statistics-table'] }
39
- ],
40
- ].each { |(args, xpect_options)|
41
- title, data_set_or_array, chart_specs = args
42
-
43
- it "renders #{ title } correctly" do
44
- check_render_expectations(
45
- Exploration.new(*args, true).render,
46
- xpect_options
47
- )
48
- end
49
-
50
- }
51
-
6
+ let(:exploration) {
7
+ Exploration.new(
8
+ 'the title',
9
+ [{ name: 'ds1', values: [1,2,3] }],
10
+ true
11
+ )
12
+ }
13
+ it 'computes a dom id' do
14
+ exploration.dom_id.must_match /rde-exploration-./
52
15
  end
53
16
 
17
+ # describe "integration test" do
18
+
19
+ # def check_render_expectations(rendered_string, options)
20
+ # r = true
21
+
22
+ # if options[:has_charts]
23
+ # options[:has_charts].each { |chart_name|
24
+ # # TODO: use Nokogiri to test that it is a div class
25
+ # rendered_string.must_match(
26
+ # Regexp.new(Regexp.escape("rde-#{ chart_name }"))
27
+ # )
28
+ # }
29
+ # end
30
+
31
+ # r
32
+ # end
33
+
34
+ # [
35
+ # [
36
+ # ['Univariate Integer data', [1, 2, 3]],
37
+ # { has_charts: ['histogram-quantitative', 'descriptive-statistics-table'] }
38
+ # ],
39
+ # [
40
+ # ['Univariate Decimal data', [1.0, 2.0, 3.0]],
41
+ # { has_charts: ['histogram-quantitative', 'descriptive-statistics-table'] }
42
+ # ],
43
+ # [
44
+ # ['Univariate Temporal data', [DateTime.new(2015,2,7)]],
45
+ # { has_charts: ['histogram-temporal', 'descriptive-statistics-table'] }
46
+ # ],
47
+ # [
48
+ # ['Univariate Categorical data', ['a', 'b', 'c']],
49
+ # { has_charts: ['histogram-categorical', 'pie-chart', 'descriptive-statistics-table'] }
50
+ # ],
51
+ # ].each { |(args, xpect_options)|
52
+ # title, data_set_or_array, chart_specs = args
53
+
54
+ # it "renders #{ title } correctly" do
55
+ # check_render_expectations(
56
+ # Exploration.new(*args, true).render,
57
+ # xpect_options
58
+ # )
59
+ # end
60
+
61
+ # }
62
+
63
+ # end
64
+
54
65
  end
55
66
  end
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: 1.0.1
4
+ version: 1.0.2
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-02-09 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -166,6 +166,20 @@ dependencies:
166
166
  - - ">="
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
+ - !ruby/object:Gem::Dependency
170
+ name: yui-compressor
171
+ requirement: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ type: :development
177
+ prerelease: false
178
+ version_requirements: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
169
183
  description: rails-data-explorer is a Rails Engine plugin that makes it easy to explore
170
184
  the data in your app using charts and statistics.
171
185
  email: jhund@clearcove.ca
@@ -183,6 +197,8 @@ files:
183
197
  - app/assets/images/rails-data-explorer/multiple_bivariate_small.png
184
198
  - doc/how_to/release.md
185
199
  - doc/how_to/trouble_when_packaging_assets.md
200
+ - doc/rails-data-explorer-screenshot-all-univariate.png
201
+ - doc/rails-data-explorer-screenshot-plan-bivariate.png
186
202
  - doc/rails-data-explorer-screenshot.png
187
203
  - lib/rails-data-explorer-no-rails.rb
188
204
  - lib/rails-data-explorer.rb