chartx 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,7 +15,8 @@ And then execute:
15
15
 
16
16
  To add the necessary javascript files into your asset pipeline add
17
17
 
18
- //= require chartx
18
+ //= require chartx-core
19
+ //= require chartx-model
19
20
 
20
21
  in ```app/assets/javascripts/application.js```
21
22
 
@@ -4,8 +4,6 @@ require "erb"
4
4
  module Chartx
5
5
  module Helper
6
6
 
7
- #pie_chart has different input data format LoL
8
- #TODO: fix the input data format
9
7
  def pie_chart(data_source, options = {})
10
8
  chartx "pie", data_source, options
11
9
  end
@@ -69,6 +67,7 @@ module Chartx
69
67
  y2_axis_format = options.delete(:y2_axis_format) || '.2f'
70
68
 
71
69
  clip_edge = options.delete(:clip_edge) || true
70
+ duration = options.delete(:duration) || 500
72
71
 
73
72
  case chart_type
74
73
  when "discrete_bar"
@@ -93,13 +92,20 @@ module Chartx
93
92
 
94
93
  when "multi_bar"
95
94
  chart_str = "var chart = nv.models.multiBarChart()
95
+ .x(function(d) { return d.#{x_name} })
96
+ .y(function(d) { return d.#{y_name} })
96
97
  .width(#{width})
97
- .height(#{height});
98
+ .height(#{height})
99
+ .staggerLabels(#{stagger_labels})
100
+ .tooltips(#{show_tooltips})
101
+ .showValues(#{show_values});
98
102
  chart.xAxis.tickFormat(d3.format('#{x_axis_format}'));
99
- chart.yAxis.tickFormat(d3.format('#{y_axis_format}'));"
100
-
103
+ chart.yAxis.tickFormat(d3.format('#{y_axis_format}'));"
104
+
101
105
  when "line"
102
106
  chart_str = "var chart = nv.models.lineChart()
107
+ .x(function(d) { return d.#{x_name} })
108
+ .y(function(d) { return d.#{y_name} })
103
109
  .width(#{width})
104
110
  .height(#{height});
105
111
  chart.xAxis.tickFormat(d3.format('#{x_axis_format}'));
@@ -118,6 +124,8 @@ module Chartx
118
124
 
119
125
  when "line_with_focus"
120
126
  chart_str = "var chart = nv.models.lineWithFocusChart()
127
+ .x(function(d) { return d.#{x_name} })
128
+ .y(function(d) { return d.#{y_name} })
121
129
  .width(#{width})
122
130
  .height(#{height});
123
131
  chart.xAxis.tickFormat(d3.format('#{x_axis_format}'));
@@ -126,10 +134,12 @@ module Chartx
126
134
 
127
135
  when "scatter"
128
136
  chart_str = "chart = nv.models.scatterChart()
137
+ .x(function(d) { return d.#{x_name} })
138
+ .y(function(d) { return d.#{y_name} })
129
139
  .showDistX(#{show_dist_x})
130
140
  .showDistY(#{show_dist_y})
131
141
  .useVoronoi(true)
132
- .color(d3.scale.category10().range())
142
+ .color(d3.scale.#{color}.range())
133
143
  .width(#{width})
134
144
  .height(#{height});
135
145
  chart.xAxis.tickFormat(d3.format('#{x_axis_format}'));
@@ -149,26 +159,26 @@ module Chartx
149
159
  chart_str = "var chart = nv.models.bulletChart();"
150
160
  end
151
161
 
152
- html = <<HTML
162
+ html = <<-HTML
153
163
  <div id="#{ERB::Util.html_escape(elem_id)}" style="height: #{ERB::Util.html_escape(height)}px;">
154
164
  <svg></svg>
155
165
  </div>
156
- HTML
166
+ HTML
157
167
 
158
- js = <<JS
168
+ js = <<-JS
159
169
  <script type="text/javascript">
160
170
  nv.addGraph(function() {
161
171
  #{chart_str}
162
172
 
163
173
  d3.select("##{elem_id} svg")
164
174
  .datum(#{data_source.to_json})
165
- .transition().duration(500)
175
+ .transition().duration(#{duration})
166
176
  .call(chart);
167
177
 
168
178
  return chart;
169
179
  });
170
180
  </script>
171
- JS
181
+ JS
172
182
 
173
183
  if options[:content_for]
174
184
  content_for(options[:content_for]) { js.respond_to?(:html_safe) ? js.html_safe : js }
@@ -1,3 +1,3 @@
1
1
  module Chartx
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-17 00:00:00.000000000 Z
12
+ date: 2013-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  segments:
172
172
  - 0
173
- hash: 3039926389988507501
173
+ hash: 4295942244449384913
174
174
  required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  none: false
176
176
  requirements:
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  segments:
181
181
  - 0
182
- hash: 3039926389988507501
182
+ hash: 4295942244449384913
183
183
  requirements: []
184
184
  rubyforge_project:
185
185
  rubygems_version: 1.8.25