d3c3-rails 0.1.0

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.
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require_tree ./d3c3_rails
3
+ */
@@ -0,0 +1,203 @@
1
+ /*-- Chart --*/
2
+
3
+ .c3 svg {
4
+ font: 10px sans-serif;
5
+ }
6
+ .c3 path, .c3 line {
7
+ fill: none;
8
+ stroke: #000;
9
+ }
10
+ .c3 text {
11
+ -webkit-user-select: none;
12
+ -moz-user-select: none;
13
+ user-select: none;
14
+ }
15
+
16
+ .c3-legend-item-tile,
17
+ .c3-xgrid-focus,
18
+ .c3-ygrid,
19
+ .c3-event-rect,
20
+ .c3-bars path {
21
+ shape-rendering: crispEdges;
22
+ }
23
+
24
+ .c3-chart-arc path {
25
+ stroke: #fff;
26
+
27
+ }
28
+ .c3-chart-arc text {
29
+ fill: #fff;
30
+ font-size: 13px;
31
+ }
32
+
33
+ /*-- Axis --*/
34
+
35
+ .c3-axis-x .tick {
36
+ }
37
+ .c3-axis-x-label {
38
+ }
39
+
40
+ .c3-axis-y .tick {
41
+ }
42
+ .c3-axis-y-label {
43
+ }
44
+
45
+ .c3-axis-y2 .tick {
46
+ }
47
+ .c3-axis-y2-label {
48
+ }
49
+
50
+ /*-- Grid --*/
51
+
52
+ .c3-grid line {
53
+ stroke: #aaa;
54
+ }
55
+ .c3-grid text {
56
+ fill: #aaa;
57
+ }
58
+ .c3-xgrid, .c3-ygrid {
59
+ stroke-dasharray: 3 3;
60
+ }
61
+ .c3-xgrid-focus {
62
+ }
63
+
64
+ /*-- Text on Chart --*/
65
+
66
+ .c3-text {
67
+ }
68
+
69
+ .c3-text.c3-empty {
70
+ fill: #808080;
71
+ font-size: 2em;
72
+ }
73
+
74
+ /*-- Line --*/
75
+
76
+ .c3-line {
77
+ stroke-width: 1px;
78
+ }
79
+ /*-- Point --*/
80
+
81
+ .c3-circle._expanded_ {
82
+ stroke-width: 1px;
83
+ stroke: white;
84
+ }
85
+ .c3-selected-circle {
86
+ fill: white;
87
+ stroke-width: 2px;
88
+ }
89
+
90
+ /*-- Bar --*/
91
+
92
+ .c3-bar {
93
+ stroke-width: 0;
94
+ }
95
+ .c3-bar._expanded_ {
96
+ fill-opacity: 0.75;
97
+ }
98
+
99
+ /*-- Arc --*/
100
+
101
+ .c3-chart-arcs-title {
102
+ font-size: 1.3em;
103
+ }
104
+
105
+ /*-- Focus --*/
106
+
107
+ .c3-target.c3-focused path.c3-line, .c3-target.c3-focused path.c3-step {
108
+ stroke-width: 2px;
109
+ }
110
+
111
+ /*-- Region --*/
112
+
113
+ .c3-region {
114
+ fill: steelblue;
115
+ fill-opacity: .1;
116
+ }
117
+
118
+ /*-- Brush --*/
119
+
120
+ .c3-brush .extent {
121
+ fill-opacity: .1;
122
+ }
123
+
124
+ /*-- Select - Drag --*/
125
+
126
+ .c3-dragarea {
127
+ }
128
+
129
+ /*-- Legend --*/
130
+
131
+ .c3-legend-item {
132
+ font-size: 12px;
133
+ }
134
+
135
+ .c3-legend-background {
136
+ opacity: 0.75;
137
+ fill: white;
138
+ stroke: lightgray;
139
+ stroke-width: 1
140
+ }
141
+
142
+ /*-- Tooltip --*/
143
+
144
+ .c3-tooltip {
145
+ border-collapse:collapse;
146
+ border-spacing:0;
147
+ background-color:#fff;
148
+ empty-cells:show;
149
+ -webkit-box-shadow: 7px 7px 12px -9px rgb(119,119,119);
150
+ -moz-box-shadow: 7px 7px 12px -9px rgb(119,119,119);
151
+ box-shadow: 7px 7px 12px -9px rgb(119,119,119);
152
+ opacity: 0.9;
153
+ }
154
+ .c3-tooltip tr {
155
+ border:1px solid #CCC;
156
+ }
157
+ .c3-tooltip th {
158
+ background-color: #aaa;
159
+ font-size:14px;
160
+ padding:2px 5px;
161
+ text-align:left;
162
+ color:#FFF;
163
+ }
164
+ .c3-tooltip td {
165
+ font-size:13px;
166
+ padding: 3px 6px;
167
+ background-color:#fff;
168
+ border-left:1px dotted #999;
169
+ }
170
+ .c3-tooltip td > span {
171
+ display: inline-block;
172
+ width: 10px;
173
+ height: 10px;
174
+ margin-right: 6px;
175
+ }
176
+ .c3-tooltip td.value{
177
+ text-align: right;
178
+ }
179
+
180
+ .c3-area {
181
+ stroke-width: 0;
182
+ opacity: 0.2;
183
+ }
184
+
185
+ .c3-chart-arcs .c3-chart-arcs-background {
186
+ fill: #e0e0e0;
187
+ stroke: none;
188
+ }
189
+ .c3-chart-arcs .c3-chart-arcs-gauge-unit {
190
+ fill: #000;
191
+ font-size: 16px;
192
+ }
193
+ .c3-chart-arcs .c3-chart-arcs-gauge-max {
194
+ fill: #777;
195
+ }
196
+ .c3-chart-arcs .c3-chart-arcs-gauge-min {
197
+ fill: #777;
198
+ }
199
+
200
+ .c3-chart-arc .c3-gauge-value {
201
+ fill: #000;
202
+ font-size: 28px;
203
+ }
data/lib/d3c3-rails.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'd3c3-rails/version'
2
+ require 'd3c3-rails/engine'
3
+
4
+ module D3C3Rails
5
+
6
+ autoload :Generators, 'd3c3-rails/generators'
7
+ autoload :Grapher, 'd3c3-rails/grapher'
8
+ autoload :Holder, 'd3c3-rails/holder'
9
+
10
+ end
@@ -0,0 +1,9 @@
1
+ module D3C3Rails
2
+ class Engine < ::Rails::Engine
3
+
4
+ config.to_prepare do |config|
5
+ require 'd3c3-rails/grapher'
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,71 @@
1
+ require 'd3c3-rails'
2
+ require 'rails_javascript_helpers'
3
+
4
+ module D3C3Rails
5
+ # Generator methods for dialogs
6
+ module Generators
7
+
8
+ include RailsJavaScriptHelpers
9
+ include ActionView::Helpers::JavaScriptHelper
10
+ include ActionView::Helpers::TagHelper
11
+
12
+ # Create a new graph
13
+ #
14
+ # @param name [String] name of graph (maps to DOM ID)
15
+ # @param options [Hash] graph options
16
+ # @return [TrueClass]
17
+ def graph_generate(name, options={})
18
+ options[:bindto] = "##{name}"
19
+ self << "d3c3_rails.actions.generate('#{name}', #{format_type_to_js(options)});"
20
+ true
21
+ end
22
+
23
+ # Load data into graph
24
+ #
25
+ # @param name [String] name of graph
26
+ # @param options [Hash] load options
27
+ # @return [TrueClass]
28
+ def graph_load(name, options={})
29
+ graph_perform(:load, name, options)
30
+ end
31
+
32
+ # Unload data from graph
33
+ #
34
+ # @param name [String] name of graph
35
+ # @param options [Hash] unload options
36
+ # @return [TrueClass]
37
+ def graph_unload(name, options={})
38
+ graph_perform(:unload, name, options)
39
+ end
40
+
41
+ # Show columns in graph
42
+ #
43
+ # @param name [String] name of graph
44
+ # @param column_names [Array<String>] columns to show
45
+ # @return [TrueClass]
46
+ def graph_show(name, column_names=[])
47
+ graph_perform(:show, name, column_names)
48
+ end
49
+
50
+ # Hide columns in graph
51
+ #
52
+ # @param name [String] name of graph
53
+ # @param column_names [Array<String>] columns to hide
54
+ # @return [TrueClass]
55
+ def graph_hide(name, column_names=[])
56
+ graph_perform(:hide, name, column_names)
57
+ end
58
+
59
+ # Perform action on graph
60
+ #
61
+ # @param action [String] graph API method
62
+ # @param name [String] name of graph
63
+ # @param options [Object] API method parameters
64
+ # @return [TrueClass]
65
+ def graph_perform(action, name, options={})
66
+ self << "d3c3_rails.actions.get('#{name}').#{action}(#{format_type_to_js(options)});"
67
+ true
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,28 @@
1
+ require 'd3c3-rails'
2
+
3
+ module D3C3Rails
4
+ # Loads graphing helper methods into class
5
+ module Grapher
6
+
7
+ def self.included(base)
8
+ D3C3Rails::Generators.instance_methods(false).each do |method|
9
+ base.class_eval do
10
+
11
+ def _grapher_holder
12
+ @_grapher_holder ||= D3C3Rails::Holder.new
13
+ end
14
+
15
+ define_method method do |*args|
16
+ _grapher_holder.context = self
17
+ _grapher_holder.send(method, *args)
18
+ _grapher_holder.grapher_flush.html_safe
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
28
+ ActionView::Base.send(:include, D3C3Rails::Grapher)
@@ -0,0 +1,40 @@
1
+ require 'd3c3-rails'
2
+
3
+ module D3C3Rails
4
+ # Content container
5
+ class Holder
6
+
7
+ include D3C3Rails::Generators
8
+
9
+ # @return [Context] current context
10
+ attr_accessor :context
11
+
12
+ # Create new instance
13
+ #
14
+ # @param args [Hash]
15
+ # @option args [Context] :context
16
+ def initialize(args={})
17
+ @context = args[:context]
18
+ @buffer = ''
19
+ end
20
+
21
+ # Add string to buffer
22
+ #
23
+ # @param string [String]
24
+ # @return [self]
25
+ def << (string)
26
+ @buffer << string.to_s
27
+ self
28
+ end
29
+
30
+ # Clear current buffer and return content
31
+ #
32
+ # @return [String]
33
+ def grapher_flush
34
+ buf = @buffer.dup
35
+ @buffer = ''
36
+ buf
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,4 @@
1
+ module D3C3Rails
2
+ # current library version
3
+ VERSION = Gem::Version.new('0.1.0')
4
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: d3c3-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Roberts
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails_javascript_helpers
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description: D3 and C3 for Rails
42
+ email: code@chrisroberts.org
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files:
46
+ - README.md
47
+ - LICENSE
48
+ - CHANGELOG.md
49
+ files:
50
+ - CHANGELOG.md
51
+ - LICENSE
52
+ - README.md
53
+ - app/assets/javascripts/d3c3_rails.js
54
+ - app/assets/javascripts/d3c3_rails/base.js
55
+ - app/assets/javascripts/d3c3_rails/c3-0.3.0.js
56
+ - app/assets/javascripts/d3c3_rails/d3-3.4.11.js
57
+ - app/assets/stylesheets/d3c3_rails.css
58
+ - app/assets/stylesheets/d3c3_rails/c3-0.3.0.css
59
+ - lib/d3c3-rails.rb
60
+ - lib/d3c3-rails/engine.rb
61
+ - lib/d3c3-rails/generators.rb
62
+ - lib/d3c3-rails/grapher.rb
63
+ - lib/d3c3-rails/holder.rb
64
+ - lib/d3c3-rails/version.rb
65
+ homepage: http://github.com/chrisroberts/d3c3_rails
66
+ licenses:
67
+ - Apache 2.0
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.2.2
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: D3 and C3 for Rails
89
+ test_files: []
90
+ has_rdoc: