highcharts-js-rails 0.2.1 → 1.0.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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -1
  3. data/.rspec +0 -1
  4. data/.travis.yml +6 -0
  5. data/CHANGELOG.md +7 -0
  6. data/{lib/LICENSE → LICENSE} +1 -1
  7. data/README.md +16 -13
  8. data/highcharts-js-rails.gemspec +3 -5
  9. data/lib/highcharts-js-rails.rb +1 -1
  10. data/lib/highcharts.rb +4 -3
  11. data/lib/highcharts/axis/plot_bands.rb +1 -1
  12. data/lib/highcharts/axis/plot_lines.rb +1 -1
  13. data/lib/highcharts/axis/x.rb +6 -8
  14. data/lib/highcharts/axis/y.rb +6 -6
  15. data/lib/highcharts/base.rb +8 -8
  16. data/lib/highcharts/{color.rb → colors.rb} +0 -0
  17. data/lib/highcharts/engine.rb +2 -0
  18. data/lib/highcharts/legend.rb +2 -2
  19. data/lib/highcharts/plot_options.rb +13 -13
  20. data/lib/highcharts/plot_options/plot_type.rb +7 -7
  21. data/lib/highcharts/plot_options/plot_type/marker.rb +1 -1
  22. data/lib/highcharts/plot_options/plot_type/marker/states.rb +2 -2
  23. data/lib/highcharts/plot_options/plot_type/states.rb +1 -1
  24. data/lib/highcharts/plot_options/plot_type/states/hover.rb +1 -1
  25. data/lib/highcharts/point.rb +2 -2
  26. data/spec/highcharts/axis/x_spec.rb +51 -0
  27. data/spec/highcharts/base_spec.rb +55 -1
  28. data/spec/highcharts/series_spec.rb +25 -0
  29. data/spec/highcharts_spec.rb +65 -0
  30. data/spec/spec_helper.rb +4 -4
  31. data/vendor/assets/javascripts/highcharts-more.js +2290 -1387
  32. data/vendor/assets/javascripts/highcharts.js +2712 -1720
  33. data/vendor/assets/javascripts/highcharts/adapters/mootools.js +15 -30
  34. data/vendor/assets/javascripts/highcharts/adapters/prototype.js +10 -79
  35. data/vendor/assets/javascripts/highcharts/modules/canvas-tools.js +1 -1
  36. data/vendor/assets/javascripts/highcharts/modules/data.js +57 -32
  37. data/vendor/assets/javascripts/highcharts/modules/exporting.js +180 -229
  38. data/vendor/assets/javascripts/highcharts/modules/funnel.js +284 -0
  39. data/vendor/assets/javascripts/highcharts/themes/dark-blue.js +11 -20
  40. data/vendor/assets/javascripts/highcharts/themes/dark-green.js +12 -20
  41. data/vendor/assets/javascripts/highcharts/themes/gray.js +15 -20
  42. data/vendor/assets/javascripts/highcharts/themes/grid.js +8 -0
  43. metadata +34 -38
@@ -0,0 +1,284 @@
1
+ /**
2
+ * @license
3
+ * Highcharts funnel module, Beta
4
+ *
5
+ * (c) 2010-2012 Torstein Hønsi
6
+ *
7
+ * License: www.highcharts.com/license
8
+ */
9
+
10
+ /*global Highcharts */
11
+ (function (Highcharts) {
12
+
13
+ 'use strict';
14
+
15
+ // create shortcuts
16
+ var defaultOptions = Highcharts.getOptions(),
17
+ defaultPlotOptions = defaultOptions.plotOptions,
18
+ seriesTypes = Highcharts.seriesTypes,
19
+ merge = Highcharts.merge,
20
+ noop = function () {},
21
+ each = Highcharts.each;
22
+
23
+ // set default options
24
+ defaultPlotOptions.funnel = merge(defaultPlotOptions.pie, {
25
+ center: ['50%', '50%'],
26
+ width: '90%',
27
+ neckWidth: '30%',
28
+ height: '100%',
29
+ neckHeight: '25%',
30
+
31
+ dataLabels: {
32
+ //position: 'right',
33
+ connectorWidth: 1,
34
+ connectorColor: '#606060'
35
+ },
36
+ size: true, // to avoid adapting to data label size in Pie.drawDataLabels
37
+ states: {
38
+ select: {
39
+ color: '#C0C0C0',
40
+ borderColor: '#000000',
41
+ shadow: false
42
+ }
43
+ }
44
+ });
45
+
46
+
47
+ seriesTypes.funnel = Highcharts.extendClass(seriesTypes.pie, {
48
+
49
+ type: 'funnel',
50
+ animate: noop,
51
+
52
+ /**
53
+ * Overrides the pie translate method
54
+ */
55
+ translate: function () {
56
+
57
+ var
58
+ // Get positions - either an integer or a percentage string must be given
59
+ getLength = function (length, relativeTo) {
60
+ return (/%$/).test(length) ?
61
+ relativeTo * parseInt(length, 10) / 100 :
62
+ parseInt(length, 10);
63
+ },
64
+
65
+ sum = 0,
66
+ series = this,
67
+ chart = series.chart,
68
+ plotWidth = chart.plotWidth,
69
+ plotHeight = chart.plotHeight,
70
+ cumulative = 0, // start at top
71
+ options = series.options,
72
+ center = options.center,
73
+ centerX = getLength(center[0], plotWidth),
74
+ centerY = getLength(center[0], plotHeight),
75
+ width = getLength(options.width, plotWidth),
76
+ tempWidth,
77
+ getWidthAt,
78
+ height = getLength(options.height, plotHeight),
79
+ neckWidth = getLength(options.neckWidth, plotWidth),
80
+ neckHeight = getLength(options.neckHeight, plotHeight),
81
+ neckY = height - neckHeight,
82
+ data = series.data,
83
+ path,
84
+ fraction,
85
+ half = options.dataLabels.position === 'left' ? 1 : 0,
86
+
87
+ x1,
88
+ y1,
89
+ x2,
90
+ x3,
91
+ y3,
92
+ x4,
93
+ y5;
94
+
95
+ // Return the width at a specific y coordinate
96
+ series.getWidthAt = getWidthAt = function (y) {
97
+ return y > height - neckHeight ?
98
+ neckWidth :
99
+ neckWidth + (width - neckWidth) * ((height - neckHeight - y) / (height - neckHeight));
100
+ };
101
+ series.getX = function (y, half) {
102
+ return centerX + (half ? -1 : 1) * ((getWidthAt(y) / 2) + options.dataLabels.distance);
103
+ };
104
+
105
+ // Expose
106
+ series.center = [centerX, centerY, height];
107
+ series.centerX = centerX;
108
+
109
+ /*
110
+ * Individual point coordinate naming:
111
+ *
112
+ * x1,y1 _________________ x2,y1
113
+ * \ /
114
+ * \ /
115
+ * \ /
116
+ * \ /
117
+ * \ /
118
+ * x3,y3 _________ x4,y3
119
+ *
120
+ * Additional for the base of the neck:
121
+ *
122
+ * | |
123
+ * | |
124
+ * | |
125
+ * x3,y5 _________ x4,y5
126
+ */
127
+
128
+
129
+
130
+
131
+ // get the total sum
132
+ each(data, function (point) {
133
+ sum += point.y;
134
+ });
135
+
136
+ each(data, function (point) {
137
+ // set start and end positions
138
+ y5 = null;
139
+ fraction = sum ? point.y / sum : 0;
140
+ y1 = cumulative * height;
141
+ y3 = y1 + fraction * height;
142
+ //tempWidth = neckWidth + (width - neckWidth) * ((height - neckHeight - y1) / (height - neckHeight));
143
+ tempWidth = getWidthAt(y1);
144
+ x1 = centerX - tempWidth / 2;
145
+ x2 = x1 + tempWidth;
146
+ tempWidth = getWidthAt(y3);
147
+ x3 = centerX - tempWidth / 2;
148
+ x4 = x3 + tempWidth;
149
+
150
+ // the entire point is within the neck
151
+ if (y1 > neckY) {
152
+ x1 = x3 = centerX - neckWidth / 2;
153
+ x2 = x4 = centerX + neckWidth / 2;
154
+
155
+ // the base of the neck
156
+ } else if (y3 > neckY) {
157
+ y5 = y3;
158
+
159
+ tempWidth = getWidthAt(neckY);
160
+ x3 = centerX - tempWidth / 2;
161
+ x4 = x3 + tempWidth;
162
+
163
+ y3 = neckY;
164
+ }
165
+
166
+ // save the path
167
+ path = [
168
+ 'M',
169
+ x1, y1,
170
+ 'L',
171
+ x2, y1,
172
+ x4, y3
173
+ ];
174
+ if (y5) {
175
+ path.push(x4, y5, x3, y5);
176
+ }
177
+ path.push(x3, y3, 'Z');
178
+
179
+ // prepare for using shared dr
180
+ point.shapeType = 'path';
181
+ point.shapeArgs = { d: path };
182
+
183
+
184
+ // for tooltips and data labels
185
+ point.percentage = fraction * 100;
186
+ point.plotX = centerX;
187
+ point.plotY = (y1 + (y5 || y3)) / 2;
188
+
189
+ // Placement of tooltips and data labels
190
+ point.tooltipPos = [
191
+ centerX,
192
+ point.plotY
193
+ ];
194
+
195
+ // Slice is a noop on funnel points
196
+ point.slice = noop;
197
+
198
+ // Mimicking pie data label placement logic
199
+ point.half = half;
200
+
201
+ cumulative += fraction;
202
+ });
203
+
204
+
205
+ series.setTooltipPoints();
206
+ },
207
+ /**
208
+ * Draw a single point (wedge)
209
+ * @param {Object} point The point object
210
+ * @param {Object} color The color of the point
211
+ * @param {Number} brightness The brightness relative to the color
212
+ */
213
+ drawPoints: function () {
214
+ var series = this,
215
+ options = series.options,
216
+ chart = series.chart,
217
+ renderer = chart.renderer;
218
+
219
+ each(series.data, function (point) {
220
+
221
+ var graphic = point.graphic,
222
+ shapeArgs = point.shapeArgs;
223
+
224
+ if (!graphic) { // Create the shapes
225
+ point.graphic = renderer.path(shapeArgs).
226
+ attr({
227
+ fill: point.color,
228
+ stroke: options.borderColor,
229
+ 'stroke-width': options.borderWidth
230
+ }).
231
+ add(series.group);
232
+
233
+ } else { // Update the shapes
234
+ graphic.animate(shapeArgs);
235
+ }
236
+ });
237
+ },
238
+
239
+ /**
240
+ * Extend the pie data label method
241
+ */
242
+ drawDataLabels: function () {
243
+ var data = this.data,
244
+ labelDistance = this.options.dataLabels.distance,
245
+ leftSide,
246
+ sign,
247
+ point,
248
+ i = data.length,
249
+ x,
250
+ y;
251
+
252
+ // In the original pie label anticollision logic, the slots are distributed
253
+ // from one labelDistance above to one labelDistance below the pie. In funnels
254
+ // we don't want this.
255
+ this.center[2] -= 2 * labelDistance;
256
+
257
+ // Set the label position array for each point.
258
+ while (i--) {
259
+ point = data[i];
260
+ leftSide = point.half;
261
+ sign = leftSide ? 1 : -1;
262
+ y = point.plotY;
263
+ x = this.getX(y, leftSide);
264
+
265
+ // set the anchor point for data labels
266
+ point.labelPos = [
267
+ 0, // first break of connector
268
+ y, // a/a
269
+ x + (labelDistance - 5) * sign, // second break, right outside point shape
270
+ y, // a/a
271
+ x + labelDistance * sign, // landing point for connector
272
+ y, // a/a
273
+ leftSide ? 'right' : 'left', // alignment
274
+ 0 // center angle
275
+ ];
276
+ }
277
+
278
+ seriesTypes.pie.prototype.drawDataLabels.call(this);
279
+ }
280
+
281
+ });
282
+
283
+
284
+ }(Highcharts));
@@ -132,26 +132,17 @@ Highcharts.theme = {
132
132
 
133
133
  navigation: {
134
134
  buttonOptions: {
135
- backgroundColor: {
136
- linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
137
- stops: [
138
- [0.4, '#606060'],
139
- [0.6, '#333333']
140
- ]
141
- },
142
- borderColor: '#000000',
143
- symbolStroke: '#C0C0C0',
144
- hoverSymbolStroke: '#FFFFFF'
145
- }
146
- },
147
-
148
- exporting: {
149
- buttons: {
150
- exportButton: {
151
- symbolFill: '#55BE3B'
152
- },
153
- printButton: {
154
- symbolFill: '#7797BE'
135
+ symbolStroke: '#DDDDDD',
136
+ hoverSymbolStroke: '#FFFFFF',
137
+ theme: {
138
+ fill: {
139
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
140
+ stops: [
141
+ [0.4, '#606060'],
142
+ [0.6, '#333333']
143
+ ]
144
+ },
145
+ stroke: '#000000'
155
146
  }
156
147
  }
157
148
  },
@@ -130,28 +130,20 @@ Highcharts.theme = {
130
130
  }
131
131
  },
132
132
 
133
+
133
134
  navigation: {
134
135
  buttonOptions: {
135
- backgroundColor: {
136
- linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
137
- stops: [
138
- [0.4, '#606060'],
139
- [0.6, '#333333']
140
- ]
141
- },
142
- borderColor: '#000000',
143
- symbolStroke: '#C0C0C0',
144
- hoverSymbolStroke: '#FFFFFF'
145
- }
146
- },
147
-
148
- exporting: {
149
- buttons: {
150
- exportButton: {
151
- symbolFill: '#55BE3B'
152
- },
153
- printButton: {
154
- symbolFill: '#7797BE'
136
+ symbolStroke: '#DDDDDD',
137
+ hoverSymbolStroke: '#FFFFFF',
138
+ theme: {
139
+ fill: {
140
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
141
+ stops: [
142
+ [0.4, '#606060'],
143
+ [0.6, '#333333']
144
+ ]
145
+ },
146
+ stroke: '#000000'
155
147
  }
156
148
  }
157
149
  },
@@ -53,6 +53,7 @@ Highcharts.theme = {
53
53
  alternateGridColor: null,
54
54
  minorTickInterval: null,
55
55
  gridLineColor: 'rgba(255, 255, 255, .1)',
56
+ minorGridLineColor: 'rgba(255,255,255,0.07)',
56
57
  lineWidth: 0,
57
58
  tickWidth: 0,
58
59
  labels: {
@@ -100,6 +101,9 @@ Highcharts.theme = {
100
101
 
101
102
 
102
103
  plotOptions: {
104
+ series: {
105
+ shadow: true
106
+ },
103
107
  line: {
104
108
  dataLabels: {
105
109
  color: '#CCC'
@@ -131,26 +135,17 @@ Highcharts.theme = {
131
135
 
132
136
  navigation: {
133
137
  buttonOptions: {
134
- backgroundColor: {
135
- linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
136
- stops: [
137
- [0.4, '#606060'],
138
- [0.6, '#333333']
139
- ]
140
- },
141
- borderColor: '#000000',
142
- symbolStroke: '#C0C0C0',
143
- hoverSymbolStroke: '#FFFFFF'
144
- }
145
- },
146
-
147
- exporting: {
148
- buttons: {
149
- exportButton: {
150
- symbolFill: '#55BE3B'
151
- },
152
- printButton: {
153
- symbolFill: '#7797BE'
138
+ symbolStroke: '#DDDDDD',
139
+ hoverSymbolStroke: '#FFFFFF',
140
+ theme: {
141
+ fill: {
142
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
143
+ stops: [
144
+ [0.4, '#606060'],
145
+ [0.6, '#333333']
146
+ ]
147
+ },
148
+ stroke: '#000000'
154
149
  }
155
150
  }
156
151
  },
@@ -88,6 +88,14 @@ Highcharts.theme = {
88
88
  style: {
89
89
  color: '#99b'
90
90
  }
91
+ },
92
+
93
+ navigation: {
94
+ buttonOptions: {
95
+ theme: {
96
+ stroke: '#CCCCCC'
97
+ }
98
+ }
91
99
  }
92
100
  };
93
101
 
metadata CHANGED
@@ -1,111 +1,107 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highcharts-js-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alex Robbin
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-26 00:00:00.000000000 Z
11
+ date: 2013-04-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: railties
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.1'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '4.1'
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.1'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '4.1'
30
33
  - !ruby/object:Gem::Dependency
31
34
  name: bundler
32
35
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
36
  requirements:
35
- - - ! '>='
37
+ - - '>='
36
38
  - !ruby/object:Gem::Version
37
39
  version: '0'
38
40
  type: :development
39
41
  prerelease: false
40
42
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
43
  requirements:
43
- - - ! '>='
44
+ - - '>='
44
45
  - !ruby/object:Gem::Version
45
46
  version: '0'
46
47
  - !ruby/object:Gem::Dependency
47
48
  name: rake
48
49
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
57
  requirements:
59
- - - ! '>='
58
+ - - '>='
60
59
  - !ruby/object:Gem::Version
61
60
  version: '0'
62
61
  - !ruby/object:Gem::Dependency
63
62
  name: rspec
64
63
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
64
  requirements:
67
- - - ! '>='
65
+ - - '>='
68
66
  - !ruby/object:Gem::Version
69
67
  version: '0'
70
68
  type: :development
71
69
  prerelease: false
72
70
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
71
  requirements:
75
- - - ! '>='
72
+ - - '>='
76
73
  - !ruby/object:Gem::Version
77
74
  version: '0'
78
75
  - !ruby/object:Gem::Dependency
79
76
  name: simplecov
80
77
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
78
  requirements:
83
- - - ! '>='
79
+ - - '>='
84
80
  - !ruby/object:Gem::Version
85
81
  version: '0'
86
82
  type: :development
87
83
  prerelease: false
88
84
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
85
  requirements:
91
- - - ! '>='
86
+ - - '>='
92
87
  - !ruby/object:Gem::Version
93
88
  version: '0'
94
89
  description: Easily configure a Highcharts JS chart for use in a Rails application
95
90
  email:
96
- - agrobbin@gmail.com
91
+ - alex@robbinsweb.biz
97
92
  executables: []
98
93
  extensions: []
99
94
  extra_rdoc_files: []
100
95
  files:
101
96
  - .gitignore
102
97
  - .rspec
98
+ - .travis.yml
103
99
  - CHANGELOG.md
104
100
  - Gemfile
101
+ - LICENSE
105
102
  - README.md
106
103
  - Rakefile
107
104
  - highcharts-js-rails.gemspec
108
- - lib/LICENSE
109
105
  - lib/highcharts-js-rails.rb
110
106
  - lib/highcharts.rb
111
107
  - lib/highcharts/axis.rb
@@ -117,7 +113,7 @@ files:
117
113
  - lib/highcharts/axis/y.rb
118
114
  - lib/highcharts/base.rb
119
115
  - lib/highcharts/chart.rb
120
- - lib/highcharts/color.rb
116
+ - lib/highcharts/colors.rb
121
117
  - lib/highcharts/credits.rb
122
118
  - lib/highcharts/engine.rb
123
119
  - lib/highcharts/labels.rb
@@ -134,7 +130,10 @@ files:
134
130
  - lib/highcharts/series.rb
135
131
  - lib/highcharts/title.rb
136
132
  - lib/highcharts/tooltip.rb
133
+ - spec/highcharts/axis/x_spec.rb
137
134
  - spec/highcharts/base_spec.rb
135
+ - spec/highcharts/series_spec.rb
136
+ - spec/highcharts_spec.rb
138
137
  - spec/spec_helper.rb
139
138
  - vendor/assets/javascripts/highcharts-more.js
140
139
  - vendor/assets/javascripts/highcharts.js
@@ -143,6 +142,7 @@ files:
143
142
  - vendor/assets/javascripts/highcharts/modules/canvas-tools.js
144
143
  - vendor/assets/javascripts/highcharts/modules/data.js
145
144
  - vendor/assets/javascripts/highcharts/modules/exporting.js
145
+ - vendor/assets/javascripts/highcharts/modules/funnel.js
146
146
  - vendor/assets/javascripts/highcharts/themes/dark-blue.js
147
147
  - vendor/assets/javascripts/highcharts/themes/dark-green.js
148
148
  - vendor/assets/javascripts/highcharts/themes/gray.js
@@ -150,34 +150,30 @@ files:
150
150
  - vendor/assets/javascripts/highcharts/themes/skies.js
151
151
  homepage: https://github.com/agrobbin/highcharts-js-rails
152
152
  licenses: []
153
+ metadata: {}
153
154
  post_install_message:
154
155
  rdoc_options: []
155
156
  require_paths:
156
157
  - lib
157
158
  required_ruby_version: !ruby/object:Gem::Requirement
158
- none: false
159
159
  requirements:
160
- - - ! '>='
160
+ - - '>='
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
- segments:
164
- - 0
165
- hash: 3166843013317291240
166
163
  required_rubygems_version: !ruby/object:Gem::Requirement
167
- none: false
168
164
  requirements:
169
- - - ! '>='
165
+ - - '>='
170
166
  - !ruby/object:Gem::Version
171
167
  version: '0'
172
- segments:
173
- - 0
174
- hash: 3166843013317291240
175
168
  requirements: []
176
169
  rubyforge_project: highcharts-js-rails
177
- rubygems_version: 1.8.25
170
+ rubygems_version: 2.0.3
178
171
  signing_key:
179
- specification_version: 3
172
+ specification_version: 4
180
173
  summary: Easily configure a Highcharts JS chart for use in a Rails application
181
174
  test_files:
175
+ - spec/highcharts/axis/x_spec.rb
182
176
  - spec/highcharts/base_spec.rb
177
+ - spec/highcharts/series_spec.rb
178
+ - spec/highcharts_spec.rb
183
179
  - spec/spec_helper.rb