chartkick 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chartkick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +8 -2
- data/Rakefile +7 -0
- data/app/assets/javascripts/chartkick.js +36 -46
- data/chartkick.gemspec +1 -0
- data/lib/chartkick/helper.rb +1 -0
- data/lib/chartkick/version.rb +1 -1
- data/test/chartkick_test.rb +24 -0
- data/test/test_helper.rb +4 -0
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d0f0bc351764e3b7e4667d14958ba9672d72949
|
4
|
+
data.tar.gz: 4d063d2c8ed4d3e6443f8d7ed39c8b2bca48636a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 747033c51547a541ce97c4e0c193cd5049484e7cc918df5df3e1c29c453b87f3ac61f0a19e6024f39e9e688bb9f6b419c0267d991491dd5f3d06ef7a6d85907b
|
7
|
+
data.tar.gz: fa38a2827ad09bb112307fa9ba9d8dd4ce7f7560dc3d6b6927c7954941567f90e1f53e0f5b1a7069821ad758b049a5bcfa6852424beb5c4ee5992edacd3f9281
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -58,18 +58,24 @@ end
|
|
58
58
|
|
59
59
|
### Options
|
60
60
|
|
61
|
-
|
61
|
+
Id and height
|
62
62
|
|
63
63
|
```erb
|
64
64
|
<%= line_chart User.group_by_day(:created_at).count, :id => "users-chart", :height => "500px" %>
|
65
65
|
```
|
66
66
|
|
67
|
-
|
67
|
+
Min and max values (except pie chart)
|
68
68
|
|
69
69
|
```erb
|
70
70
|
<%= line_chart User.group_by_day(:created_at).count, :min => 1000, :max => 5000 %>
|
71
71
|
```
|
72
72
|
|
73
|
+
You can pass options directly to the charting library with:
|
74
|
+
|
75
|
+
```erb
|
76
|
+
<%= line_chart User.group_by_day(:created_at).count, :library => {:backgroundColor => "#eee"} %>
|
77
|
+
```
|
78
|
+
|
73
79
|
### Data
|
74
80
|
|
75
81
|
Pass data as a Hash or Array
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* Chartkick.js
|
3
3
|
* Create beautiful Javascript charts with minimal code
|
4
4
|
* https://github.com/ankane/chartkick.js
|
5
|
-
* v1.0.
|
5
|
+
* v1.0.2
|
6
6
|
* MIT License
|
7
7
|
*/
|
8
8
|
|
@@ -12,43 +12,40 @@
|
|
12
12
|
(function() {
|
13
13
|
'use strict';
|
14
14
|
|
15
|
-
//
|
16
|
-
function clone(obj) {
|
17
|
-
var copy, i, attr, len;
|
18
|
-
|
19
|
-
// Handle the 3 simple types, and null or undefined
|
20
|
-
if (null === obj || "object" !== typeof obj) {
|
21
|
-
return obj;
|
22
|
-
}
|
15
|
+
// helpers
|
23
16
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
copy.setTime(obj.getTime());
|
28
|
-
return copy;
|
29
|
-
}
|
17
|
+
function isArray(variable) {
|
18
|
+
return Object.prototype.toString.call(variable) === "[object Array]";
|
19
|
+
}
|
30
20
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
for (i = 0, len = obj.length; i < len; i++) {
|
35
|
-
copy[i] = clone(obj[i]);
|
36
|
-
}
|
37
|
-
return copy;
|
38
|
-
}
|
21
|
+
function isPlainObject(variable) {
|
22
|
+
return variable instanceof Object;
|
23
|
+
}
|
39
24
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
25
|
+
// https://github.com/madrobby/zepto/blob/master/src/zepto.js
|
26
|
+
function extend(target, source) {
|
27
|
+
var key;
|
28
|
+
for (key in source) {
|
29
|
+
if (isPlainObject(source[key]) || isArray(source[key])) {
|
30
|
+
if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
|
31
|
+
target[key] = {};
|
32
|
+
}
|
33
|
+
if (isArray(source[key]) && !isArray(target[key])) {
|
34
|
+
target[key] = [];
|
46
35
|
}
|
36
|
+
extend(target[key], source[key]);
|
37
|
+
}
|
38
|
+
else if (source[key] !== undefined) {
|
39
|
+
target[key] = source[key];
|
47
40
|
}
|
48
|
-
return copy;
|
49
41
|
}
|
42
|
+
}
|
50
43
|
|
51
|
-
|
44
|
+
function merge(obj1, obj2) {
|
45
|
+
var target = {};
|
46
|
+
extend(target, obj1);
|
47
|
+
extend(target, obj2);
|
48
|
+
return target;
|
52
49
|
}
|
53
50
|
|
54
51
|
// https://github.com/Do/iso8601.js
|
@@ -101,7 +98,7 @@
|
|
101
98
|
|
102
99
|
function jsOptionsFunc(defaultOptions, hideLegend, setMin, setMax) {
|
103
100
|
return function(series, opts) {
|
104
|
-
var options =
|
101
|
+
var options = merge({}, defaultOptions);
|
105
102
|
|
106
103
|
// hide legend
|
107
104
|
// this is *not* an external option!
|
@@ -122,6 +119,9 @@
|
|
122
119
|
setMax(options, opts.max);
|
123
120
|
}
|
124
121
|
|
122
|
+
// merge library last
|
123
|
+
options = merge(options, opts.library || {});
|
124
|
+
|
125
125
|
return options;
|
126
126
|
};
|
127
127
|
}
|
@@ -196,7 +196,7 @@
|
|
196
196
|
};
|
197
197
|
|
198
198
|
renderPieChart = function(element, series, opts) {
|
199
|
-
var options =
|
199
|
+
var options = merge(defaultOptions, opts.library || {});
|
200
200
|
options.chart = {renderTo: element.id};
|
201
201
|
options.series = [{
|
202
202
|
type: "pie",
|
@@ -314,10 +314,6 @@
|
|
314
314
|
|
315
315
|
var jsOptions = jsOptionsFunc(defaultOptions, hideLegend, setMin, setMax);
|
316
316
|
|
317
|
-
var sortByNumber = function(a, b) {
|
318
|
-
return a[0] - b[0];
|
319
|
-
};
|
320
|
-
|
321
317
|
// cant use object as key
|
322
318
|
var createDataTable = function(series, columnType) {
|
323
319
|
var data = new google.visualization.DataTable();
|
@@ -345,7 +341,7 @@
|
|
345
341
|
}
|
346
342
|
}
|
347
343
|
if (columnType === "datetime") {
|
348
|
-
rows2.sort(
|
344
|
+
rows2.sort(sortByTime);
|
349
345
|
}
|
350
346
|
data.addRows(rows2);
|
351
347
|
|
@@ -363,7 +359,7 @@
|
|
363
359
|
|
364
360
|
renderPieChart = function(element, series, opts) {
|
365
361
|
waitForLoaded(function() {
|
366
|
-
var options =
|
362
|
+
var options = merge(defaultOptions, opts.library || {});
|
367
363
|
options.chartArea = {
|
368
364
|
top: "10%",
|
369
365
|
height: "80%"
|
@@ -437,12 +433,6 @@
|
|
437
433
|
}
|
438
434
|
}
|
439
435
|
|
440
|
-
// helpers
|
441
|
-
|
442
|
-
function isArray(variable) {
|
443
|
-
return Object.prototype.toString.call(variable) === "[object Array]";
|
444
|
-
}
|
445
|
-
|
446
436
|
// type conversions
|
447
437
|
|
448
438
|
function toStr(n) {
|
@@ -535,7 +525,7 @@
|
|
535
525
|
if (typeof element === "string") {
|
536
526
|
element = document.getElementById(element);
|
537
527
|
}
|
538
|
-
fetchDataSource(element, data,
|
528
|
+
fetchDataSource(element, data, opts || {}, callback);
|
539
529
|
}
|
540
530
|
|
541
531
|
// define classes
|
data/chartkick.gemspec
CHANGED
data/lib/chartkick/helper.rb
CHANGED
data/lib/chartkick/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class TestChartkick < Minitest::Test
|
4
|
+
include Chartkick::Helper
|
5
|
+
|
6
|
+
# TODO actual tests
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@data = [[34, 42], [56, 49]]
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_line_chart
|
13
|
+
assert line_chart(@data)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_pie_chart
|
17
|
+
assert pie_chart(@data)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_column_chart
|
21
|
+
assert column_chart(@data)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chartkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Create beautiful Javascript charts with one line of Ruby
|
42
56
|
email:
|
43
57
|
- acekane1@gmail.com
|
@@ -59,6 +73,8 @@ files:
|
|
59
73
|
- lib/chartkick/rails.rb
|
60
74
|
- lib/chartkick/sinatra.rb
|
61
75
|
- lib/chartkick/version.rb
|
76
|
+
- test/chartkick_test.rb
|
77
|
+
- test/test_helper.rb
|
62
78
|
homepage: ''
|
63
79
|
licenses:
|
64
80
|
- MIT
|
@@ -83,4 +99,6 @@ rubygems_version: 2.0.0
|
|
83
99
|
signing_key:
|
84
100
|
specification_version: 4
|
85
101
|
summary: Create beautiful Javascript charts with one line of Ruby
|
86
|
-
test_files:
|
102
|
+
test_files:
|
103
|
+
- test/chartkick_test.rb
|
104
|
+
- test/test_helper.rb
|