chartify 0.1.0 → 0.1.1
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/README.md +2 -2
- data/Rakefile +2 -2
- data/lib/{charter.rb → chartify.rb} +3 -3
- data/lib/{charter → chartify}/bar_chart.rb +2 -2
- data/lib/{charter → chartify}/chart_base.rb +8 -8
- data/lib/{charter → chartify}/config.rb +2 -2
- data/lib/{charter → chartify}/factory.rb +6 -6
- data/lib/{charter → chartify}/gruff_themes.rb +1 -1
- data/lib/{charter → chartify}/line_chart.rb +3 -3
- data/lib/{charter → chartify}/pie_chart.rb +3 -3
- data/lib/chartify/version.rb +3 -0
- data/lib/{charter → chartify}/web_chart/google_chart/bar_chart.rb +5 -5
- data/lib/{charter → chartify}/web_chart/google_chart/google_chart_module.rb +2 -2
- data/lib/{charter → chartify}/web_chart/google_chart/line_chart.rb +5 -5
- data/lib/{charter → chartify}/web_chart/google_chart/pie_chart.rb +5 -5
- data/lib/tasks/{charter_tasks.rake → chartify_tasks.rake} +1 -1
- metadata +16 -16
- data/lib/charter/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e43f72a8d875e3c910d4cd10326ef74c24005324
|
4
|
+
data.tar.gz: b671a8ad3a32d9e81a1905b6ce4f21c1f0b7c232
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 570d6be7cfa5b7263bae328533095e3ed987fa7da7c7f51506a7c5433bb8f16d5b129d80d8d22e203afee17e19191778907a7c4a6765559b5a7a522ae92dce35
|
7
|
+
data.tar.gz: 48a44e598cc148a5639f8c21071cfc2dec09cb070eb2a2533164fa705113d2a99a94a4b58281266a45fae174292eef1455c3c176e1cf29cb6ccaa5684575ec7b
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Chartify
|
2
2
|
=======
|
3
3
|
The purpose of this gem is to capture data to create a chart, in an object, so that we can do the following things
|
4
4
|
|
@@ -24,7 +24,7 @@ For generating image from the chart data we are using [Gruff](https://github.com
|
|
24
24
|
|
25
25
|
Here are some sample code to generate graph object and render to web.
|
26
26
|
```ruby
|
27
|
-
@chart =
|
27
|
+
@chart = Chartify::Factory.build(:line) do |chart|
|
28
28
|
chart.data = [{hours_remain: 100, estimated_hours_remain: 100, day: 3.days.ago.to_date},
|
29
29
|
{hours_remain: 50, estimated_hours_remain: 45, day: 2.days.ago.to_date},
|
30
30
|
{hours_remain: 5, estimated_hours_remain: 10, day: 1.days.ago.to_date}]
|
data/Rakefile
CHANGED
@@ -25,10 +25,10 @@ begin
|
|
25
25
|
require 'rdoc/task'
|
26
26
|
|
27
27
|
Rake::RDocTask.new do |rdoc|
|
28
|
-
require '
|
28
|
+
require 'chartify/version'
|
29
29
|
|
30
30
|
rdoc.rdoc_dir = 'rdoc'
|
31
|
-
rdoc.title = "
|
31
|
+
rdoc.title = "Chartify #{Chartify::VERSION}"
|
32
32
|
rdoc.rdoc_files.include('README*')
|
33
33
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
34
34
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module
|
2
|
-
autoload :Configuration, "
|
1
|
+
module Chartify
|
2
|
+
autoload :Configuration, "chartify/config"
|
3
3
|
|
4
4
|
def self.configure(&block)
|
5
|
-
yield @config ||=
|
5
|
+
yield @config ||= Chartify::Configuration.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.config
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'chartify/gruff_themes'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Chartify
|
4
4
|
class ChartBase
|
5
5
|
attr_accessor :title, :data, :columns, :label_column
|
6
6
|
|
@@ -18,10 +18,10 @@ module Charter
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def render_chart(html_dom_id, options = {})
|
21
|
-
api_name = options[:web_api_name] ||
|
21
|
+
api_name = options[:web_api_name] || Chartify.config.web_api_name.to_s
|
22
22
|
class_name = self.class.name.split("::")[1]
|
23
|
-
load "
|
24
|
-
chart = "
|
23
|
+
load "chartify/web_chart/#{api_name}/#{class_name.underscore}.rb"
|
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
27
|
#{chart.include_js if chart.respond_to?(:include_js)}
|
@@ -43,7 +43,7 @@ module Charter
|
|
43
43
|
chart_type = "Gruff::#{chart_type}".constantize
|
44
44
|
|
45
45
|
g = chart_type.new
|
46
|
-
g.theme =
|
46
|
+
g.theme = Chartify::Themes::GOOGLE_CHART
|
47
47
|
g.title = self.title
|
48
48
|
g
|
49
49
|
end
|
@@ -109,11 +109,11 @@ module Charter
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def config
|
112
|
-
@config ||=
|
112
|
+
@config ||= Chartify.config
|
113
113
|
end
|
114
114
|
|
115
115
|
def web_config
|
116
|
-
@web_config ||=
|
116
|
+
@web_config ||= Chartify.config.web_config
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module
|
1
|
+
module Chartify
|
2
2
|
class Configuration
|
3
3
|
include ActiveSupport::Configurable
|
4
4
|
config_accessor :web_api_name
|
5
5
|
config_accessor :chart
|
6
6
|
|
7
7
|
def web(&block)
|
8
|
-
yield @web_config ||=
|
8
|
+
yield @web_config ||= Chartify::WebConfiguration.new
|
9
9
|
end
|
10
10
|
|
11
11
|
def web_config
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
1
|
+
require 'chartify/gruff_themes'
|
2
|
+
require 'chartify/line_chart'
|
3
|
+
require 'chartify/pie_chart'
|
4
|
+
require 'chartify/bar_chart'
|
5
5
|
|
6
|
-
module
|
6
|
+
module Chartify
|
7
7
|
class Factory
|
8
8
|
# @param type can be of line, pie, bar etc
|
9
9
|
def self.build(type, &block)
|
10
10
|
raise "type has to be a symbol" unless type.kind_of? Symbol
|
11
|
-
chart = "
|
11
|
+
chart = "Chartify::#{type.to_s.camelize}Chart".constantize.new
|
12
12
|
block.call chart
|
13
13
|
chart
|
14
14
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'chartify/chart_base'
|
2
2
|
require 'gruff'
|
3
3
|
|
4
4
|
# Example
|
5
5
|
# -------
|
6
|
-
#
|
6
|
+
# Chartify::Factory.build(:line) do |chart|
|
7
7
|
# chart.data = [{hours_remain: 100, estimated_hours_remain: 100, day: 3.days.ago.to_date},
|
8
8
|
# {hours_remain: 50, estimated_hours_remain: 45, day: 2.days.ago.to_date},
|
9
9
|
# {hours_remain: 5, estimated_hours_remain: 10, day: 1.days.ago.to_date}]
|
@@ -11,7 +11,7 @@ require 'gruff'
|
|
11
11
|
# chart.label_column = :day
|
12
12
|
# end
|
13
13
|
|
14
|
-
module
|
14
|
+
module Chartify
|
15
15
|
class LineChart < ChartBase
|
16
16
|
def to_blob
|
17
17
|
g = prepare_gruff(:line)
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require '
|
1
|
+
require 'chartify/chart_base'
|
2
2
|
require 'gruff'
|
3
3
|
|
4
4
|
# Example
|
5
5
|
# -------
|
6
|
-
#
|
6
|
+
# Chartify::Factory.build(:pie) do |chart|
|
7
7
|
# chart.data = {'ruby' => 100,
|
8
8
|
# 'python' => 12}
|
9
9
|
# chart.columns = ['Language', 'Usage']
|
10
10
|
# end
|
11
|
-
module
|
11
|
+
module Chartify
|
12
12
|
class PieChart < ChartBase
|
13
13
|
def to_blob
|
14
14
|
g = prepare_gruff(:pie)
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'chartify/bar_chart'
|
2
|
+
require 'chartify/web_chart/google_chart/google_chart_module'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Chartify
|
5
5
|
module WebChart
|
6
6
|
module GoogleChart
|
7
|
-
class BarChart <
|
8
|
-
include
|
7
|
+
class BarChart < Chartify::BarChart
|
8
|
+
include Chartify::WebChart::GoogleChart::GoogleChartModule
|
9
9
|
|
10
10
|
def render(html_dom_id)
|
11
11
|
js = <<-JS
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'chartify/line_chart'
|
2
|
+
require 'chartify/web_chart/google_chart/google_chart_module'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Chartify
|
5
5
|
module WebChart
|
6
6
|
module GoogleChart
|
7
|
-
class LineChart <
|
8
|
-
include
|
7
|
+
class LineChart < Chartify::LineChart
|
8
|
+
include Chartify::WebChart::GoogleChart::GoogleChartModule
|
9
9
|
|
10
10
|
def render(html_dom_id)
|
11
11
|
js = <<-JS
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'chartify/pie_chart'
|
2
|
+
require 'chartify/web_chart/google_chart/google_chart_module'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Chartify
|
5
5
|
module WebChart
|
6
6
|
module GoogleChart
|
7
|
-
class PieChart <
|
8
|
-
include
|
7
|
+
class PieChart < Chartify::PieChart
|
8
|
+
include Chartify::WebChart::GoogleChart::GoogleChartModule
|
9
9
|
|
10
10
|
# Js data
|
11
11
|
# var data = google.visualization.arrayToDataTable([
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chartify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A.K.M. Ashrafuzzaman
|
@@ -153,21 +153,21 @@ files:
|
|
153
153
|
- MIT-LICENSE
|
154
154
|
- README.md
|
155
155
|
- Rakefile
|
156
|
-
- lib/
|
157
|
-
- lib/
|
158
|
-
- lib/
|
159
|
-
- lib/
|
160
|
-
- lib/
|
161
|
-
- lib/
|
162
|
-
- lib/
|
163
|
-
- lib/
|
164
|
-
- lib/
|
165
|
-
- lib/
|
166
|
-
- lib/
|
167
|
-
- lib/
|
168
|
-
- lib/
|
169
|
-
- lib/tasks/
|
170
|
-
homepage: https://github.com/ashrafuzzaman/
|
156
|
+
- lib/chartify.rb
|
157
|
+
- lib/chartify/bar_chart.rb
|
158
|
+
- lib/chartify/chart_base.rb
|
159
|
+
- lib/chartify/config.rb
|
160
|
+
- lib/chartify/factory.rb
|
161
|
+
- lib/chartify/gruff_themes.rb
|
162
|
+
- lib/chartify/line_chart.rb
|
163
|
+
- lib/chartify/pie_chart.rb
|
164
|
+
- lib/chartify/version.rb
|
165
|
+
- lib/chartify/web_chart/google_chart/bar_chart.rb
|
166
|
+
- lib/chartify/web_chart/google_chart/google_chart_module.rb
|
167
|
+
- lib/chartify/web_chart/google_chart/line_chart.rb
|
168
|
+
- lib/chartify/web_chart/google_chart/pie_chart.rb
|
169
|
+
- lib/tasks/chartify_tasks.rake
|
170
|
+
homepage: https://github.com/ashrafuzzaman/chartify
|
171
171
|
licenses: []
|
172
172
|
metadata: {}
|
173
173
|
post_install_message:
|
data/lib/charter/version.rb
DELETED