chartify 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chartify/chart_base.rb +5 -6
- data/lib/chartify/version.rb +1 -1
- data/lib/chartify/web_chart/google_chart/area_chart.rb +3 -3
- data/lib/chartify/web_chart/google_chart/bar_chart.rb +3 -3
- data/lib/chartify/web_chart/google_chart/column_chart.rb +3 -3
- data/lib/chartify/web_chart/google_chart/google_chart_module.rb +5 -2
- data/lib/chartify/web_chart/google_chart/line_chart.rb +3 -3
- data/lib/chartify/web_chart/google_chart/pie_chart.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99adce276ba3286967a95fb4e69945856a37d36e
|
4
|
+
data.tar.gz: cd16d06e9a0c70b42fa6296fb17dac5879d12d25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6636b438419a0e2b0fdc1b2b1ad33e6848ff2446414a2a79ad3b6949812d2bb64b1e37266f885894b985aac322e6e8c64ee876628325b7750c146fb0878b3b9c
|
7
|
+
data.tar.gz: 22bef703c2f0fac5dc28bef9c9e9a5120b733e94b8160850ae7a9eeb0e1848fbd18cbf9f89402063feae75cfc4614a046d91bad9d8002774612f0665fada6ecf
|
data/lib/chartify/chart_base.rb
CHANGED
@@ -24,9 +24,8 @@ module Chartify
|
|
24
24
|
chart = "Chartify::WebChart::#{api_name.camelize}::#{class_name}".constantize.new
|
25
25
|
chart.data, chart.columns, chart.label_column = self.data, self.columns, self.label_column
|
26
26
|
html = <<-HTML
|
27
|
-
#{chart.include_js if chart.respond_to?(:include_js)}
|
28
27
|
<script type="application/javascript" class="chart_script">
|
29
|
-
|
28
|
+
#{chart.render(html_dom_id)}
|
30
29
|
</script>
|
31
30
|
HTML
|
32
31
|
html.html_safe
|
@@ -90,8 +89,8 @@ module Chartify
|
|
90
89
|
|
91
90
|
# Amount should be a decimal between 0 and 1. Lower means darker
|
92
91
|
def darken_color(hex_color, amount=0.4)
|
93
|
-
hex_color = hex_color.gsub('#','')
|
94
|
-
rgb = hex_color.scan(/../).map {|color| color.hex}
|
92
|
+
hex_color = hex_color.gsub('#', '')
|
93
|
+
rgb = hex_color.scan(/../).map { |color| color.hex }
|
95
94
|
rgb[0] = (rgb[0].to_i * amount).round
|
96
95
|
rgb[1] = (rgb[1].to_i * amount).round
|
97
96
|
rgb[2] = (rgb[2].to_i * amount).round
|
@@ -100,8 +99,8 @@ module Chartify
|
|
100
99
|
|
101
100
|
# Amount should be a decimal between 0 and 1. Higher means lighter
|
102
101
|
def lighten_color(hex_color, amount=0.6)
|
103
|
-
hex_color = hex_color.gsub('#','')
|
104
|
-
rgb = hex_color.scan(/../).map {|color| color.hex}
|
102
|
+
hex_color = hex_color.gsub('#', '')
|
103
|
+
rgb = hex_color.scan(/../).map { |color| color.hex }
|
105
104
|
rgb[0] = [(rgb[0].to_i + 255 * amount).round, 255].min
|
106
105
|
rgb[1] = [(rgb[1].to_i + 255 * amount).round, 255].min
|
107
106
|
rgb[2] = [(rgb[2].to_i + 255 * amount).round, 255].min
|
data/lib/chartify/version.rb
CHANGED
@@ -9,12 +9,12 @@ module Chartify
|
|
9
9
|
|
10
10
|
def render(html_dom_id)
|
11
11
|
js = <<-JS
|
12
|
-
google.load("visualization", "1", {packages:["corechart"]});
|
13
|
-
|
12
|
+
google.load("visualization", "1", {packages:["corechart"], callback:drawChart#{timestamp}});
|
13
|
+
function drawChart#{timestamp}() {
|
14
14
|
var data = google.visualization.arrayToDataTable(#{array_data_table.to_json});
|
15
15
|
var chart = new google.visualization.AreaChart(document.getElementById('#{html_dom_id}'));
|
16
16
|
chart.draw(data, #{chart_options.to_json});
|
17
|
-
}
|
17
|
+
}
|
18
18
|
JS
|
19
19
|
js.html_safe
|
20
20
|
end
|
@@ -9,12 +9,12 @@ module Chartify
|
|
9
9
|
|
10
10
|
def render(html_dom_id)
|
11
11
|
js = <<-JS
|
12
|
-
google.load("visualization", "1", {packages:["corechart"]});
|
13
|
-
|
12
|
+
google.load("visualization", "1", {packages:["corechart"], callback:drawChart#{timestamp}});
|
13
|
+
function drawChart#{timestamp}() {
|
14
14
|
var data = google.visualization.arrayToDataTable(#{array_data_table.to_json});
|
15
15
|
var chart = new google.visualization.BarChart(document.getElementById('#{html_dom_id}'));
|
16
16
|
chart.draw(data, #{chart_options.to_json});
|
17
|
-
}
|
17
|
+
}
|
18
18
|
JS
|
19
19
|
js.html_safe
|
20
20
|
end
|
@@ -9,12 +9,12 @@ module Chartify
|
|
9
9
|
|
10
10
|
def render(html_dom_id)
|
11
11
|
js = <<-JS
|
12
|
-
google.load("visualization", "1", {packages:["corechart"]});
|
13
|
-
|
12
|
+
google.load("visualization", "1", {packages:["corechart"], callback:drawChart#{timestamp}});
|
13
|
+
function drawChart#{timestamp}() {
|
14
14
|
var data = google.visualization.arrayToDataTable(#{array_data_table.to_json});
|
15
15
|
var chart = new google.visualization.ColumnChart(document.getElementById('#{html_dom_id}'));
|
16
16
|
chart.draw(data, #{chart_options.to_json});
|
17
|
-
}
|
17
|
+
}
|
18
18
|
JS
|
19
19
|
js.html_safe
|
20
20
|
end
|
@@ -28,9 +28,12 @@ module Chartify
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def timestamp
|
32
|
+
@timestamp ||= Time.now.to_i
|
33
|
+
end
|
34
|
+
|
31
35
|
def include_js
|
32
|
-
%q{<script type="text/javascript" src="https://www.google.com/jsapi
|
33
|
-
'version':'1','packages':['timeline']}]}"></script>}
|
36
|
+
%q{<script type="text/javascript" src="https://www.google.com/jsapi"></script>}
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
@@ -9,12 +9,12 @@ module Chartify
|
|
9
9
|
|
10
10
|
def render(html_dom_id)
|
11
11
|
js = <<-JS
|
12
|
-
google.load("visualization", "1", {packages:["corechart"]});
|
13
|
-
|
12
|
+
google.load("visualization", "1", {packages:["corechart"], callback:drawChart#{timestamp}});
|
13
|
+
function drawChart#{timestamp}() {
|
14
14
|
var data = google.visualization.arrayToDataTable(#{array_data_table.to_json});
|
15
15
|
var chart = new google.visualization.LineChart(document.getElementById('#{html_dom_id}'));
|
16
16
|
chart.draw(data, #{chart_options.to_json});
|
17
|
-
}
|
17
|
+
}
|
18
18
|
JS
|
19
19
|
js.html_safe
|
20
20
|
end
|
@@ -28,12 +28,12 @@ module Chartify
|
|
28
28
|
datasets.insert 0, column_names
|
29
29
|
|
30
30
|
js = <<-JS
|
31
|
-
google.load("visualization", "1", {packages:["corechart"]});
|
32
|
-
|
31
|
+
google.load("visualization", "1", {packages:["corechart"], callback:drawChart#{timestamp}});
|
32
|
+
function drawChart#{timestamp}() {
|
33
33
|
var data = google.visualization.arrayToDataTable(#{datasets.to_json});
|
34
34
|
var chart = new google.visualization.PieChart(document.getElementById('#{html_dom_id}'));
|
35
35
|
chart.draw(data, #{chart_options.to_json});
|
36
|
-
}
|
36
|
+
}
|
37
37
|
JS
|
38
38
|
js.html_safe
|
39
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chartify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A.K.M. Ashrafuzzaman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gruff
|