highcharts-rails 2.3.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,64 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highcharts-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.5
5
4
  prerelease:
5
+ version: 3.0.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Per Christian B. Viken
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-16 00:00:00.000000000 Z
12
+ date: 2013-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- prerelease: false
16
+ type: :runtime
17
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
18
19
  requirements:
19
20
  - - ! '>='
20
21
  - !ruby/object:Gem::Version
21
22
  version: '3.1'
22
- none: false
23
- type: :runtime
23
+ prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
25
26
  requirements:
26
27
  - - ! '>='
27
28
  - !ruby/object:Gem::Version
28
29
  version: '3.1'
29
- none: false
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bundler
32
- prerelease: false
32
+ type: :development
33
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
34
35
  requirements:
35
36
  - - ~>
36
37
  - !ruby/object:Gem::Version
37
38
  version: '1.0'
38
- none: false
39
- type: :development
39
+ prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
41
42
  requirements:
42
43
  - - ~>
43
44
  - !ruby/object:Gem::Version
44
45
  version: '1.0'
45
- none: false
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rails
48
- prerelease: false
48
+ type: :development
49
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
50
51
  requirements:
51
52
  - - ! '>='
52
53
  - !ruby/object:Gem::Version
53
54
  version: '3.1'
54
- none: false
55
- type: :development
55
+ prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
57
58
  requirements:
58
59
  - - ! '>='
59
60
  - !ruby/object:Gem::Version
60
61
  version: '3.1'
61
- none: false
62
62
  description: Gem that includes Highcharts (Interactive JavaScript charts for your
63
63
  web projects), in the Rails Asset Pipeline introduced in Rails 3.1
64
64
  email:
@@ -87,6 +87,7 @@ files:
87
87
  - vendor/assets/javascripts/highcharts/modules/canvas-tools.js
88
88
  - vendor/assets/javascripts/highcharts/modules/data.js
89
89
  - vendor/assets/javascripts/highcharts/modules/exporting.js
90
+ - vendor/assets/javascripts/highcharts/modules/funnel.js
90
91
  - vendor/assets/javascripts/highcharts/themes/dark-blue.js
91
92
  - vendor/assets/javascripts/highcharts/themes/dark-green.js
92
93
  - vendor/assets/javascripts/highcharts/themes/gray.js
@@ -99,17 +100,17 @@ rdoc_options: []
99
100
  require_paths:
100
101
  - lib
101
102
  required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
102
104
  requirements:
103
105
  - - ! '>='
104
106
  - !ruby/object:Gem::Version
105
107
  version: '0'
106
- none: false
107
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
108
110
  requirements:
109
111
  - - ! '>='
110
112
  - !ruby/object:Gem::Version
111
113
  version: '0'
112
- none: false
113
114
  requirements: []
114
115
  rubyforge_project:
115
116
  rubygems_version: 1.8.24