highcharts-rails 2.1.9 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v2.1.9 (2011-11-11)
2
+ * @license Highcharts JS v2.2.0 (2012-02-16)
3
3
  * Exporting module
4
4
  *
5
5
  * (c) 2010-2011 Torstein Hønsi
@@ -105,7 +105,6 @@ defaultOptions.exporting = {
105
105
  type: 'image/png',
106
106
  url: 'http://export.highcharts.com/',
107
107
  width: 800,
108
- enableImages: false,
109
108
  buttons: {
110
109
  exportButton: {
111
110
  //enabled: true,
@@ -141,16 +140,21 @@ defaultOptions.exporting = {
141
140
  type: 'image/svg+xml'
142
141
  });
143
142
  }
144
- }/*, {
143
+ }
144
+ // Enable this block to add "View SVG" to the dropdown menu
145
+ /*
146
+ ,{
147
+
145
148
  text: 'View SVG',
146
- onclick: function() {
149
+ onclick: function () {
147
150
  var svg = this.getSVG()
148
151
  .replace(/</g, '\n&lt;')
149
152
  .replace(/>/g, '&gt;');
150
153
 
151
- doc.body.innerHTML = '<pre>'+ svg +'</pre>';
154
+ doc.body.innerHTML = '<pre>' + svg + '</pre>';
152
155
  }
153
- }*/]
156
+ } // */
157
+ ]
154
158
 
155
159
  },
156
160
  printButton: {
@@ -182,9 +186,6 @@ extend(Chart.prototype, {
182
186
  sandbox,
183
187
  svg,
184
188
  seriesOptions,
185
- config,
186
- pointOptions,
187
- pointMarker,
188
189
  options = merge(chart.options, additionalOptions); // copy the options and add extra options
189
190
 
190
191
  // IE compatibility hack for generating SVG content that it doesn't really understand
@@ -214,56 +215,26 @@ extend(Chart.prototype, {
214
215
  forExport: true
215
216
  });
216
217
  options.exporting.enabled = false; // hide buttons in print
217
-
218
- if (!options.exporting.enableImages) {
219
- options.chart.plotBackgroundImage = null; // the converter doesn't handle images
220
- }
218
+ options.chart.plotBackgroundImage = null; // the converter doesn't handle images
221
219
 
222
220
  // prepare for replicating the chart
223
221
  options.series = [];
224
222
  each(chart.series, function (serie) {
225
- seriesOptions = serie.options;
223
+ seriesOptions = merge(serie.options, {
224
+ animation: false, // turn off animation
225
+ showCheckbox: false,
226
+ visible: serie.visible
227
+ });
226
228
 
227
- seriesOptions.animation = false; // turn off animation
228
- seriesOptions.showCheckbox = false;
229
- seriesOptions.visible = serie.visible;
229
+ if (!seriesOptions.isInternal) { // used for the navigator series that has its own option set
230
230
 
231
- if (!options.exporting.enableImages) {
232
231
  // remove image markers
233
232
  if (seriesOptions && seriesOptions.marker && /^url\(/.test(seriesOptions.marker.symbol)) {
234
233
  seriesOptions.marker.symbol = 'circle';
235
234
  }
236
- }
237
-
238
- seriesOptions.data = [];
239
-
240
- each(serie.data, function (point) {
241
-
242
- // extend the options by those values that can be expressed in a number or array config
243
- config = point.config;
244
- pointOptions = {
245
- x: point.x,
246
- y: point.y,
247
- name: point.name
248
- };
249
-
250
- if (typeof config === 'object' && point.config && config.constructor !== Array) {
251
- extend(pointOptions, config);
252
- }
253
235
 
254
- pointOptions.visible = point.visible;
255
- seriesOptions.data.push(pointOptions); // copy fresh updated data
256
-
257
- if (!options.exporting.enableImages) {
258
- // remove image markers
259
- pointMarker = point.config && point.config.marker;
260
- if (pointMarker && /^url\(/.test(pointMarker.symbol)) {
261
- delete pointMarker.symbol;
262
- }
263
- }
264
- });
265
-
266
- options.series.push(seriesOptions);
236
+ options.series.push(seriesOptions);
237
+ }
267
238
  });
268
239
 
269
240
  // generate the chart copy
@@ -299,9 +270,9 @@ extend(Chart.prototype, {
299
270
  .replace(/jQuery[0-9]+="[^"]+"/g, '')
300
271
  .replace(/isTracker="[^"]+"/g, '')
301
272
  .replace(/url\([^#]+#/g, 'url(#')
302
- .replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ')
303
- .replace(/ href=/g, ' xlink:href=')
304
- /*.replace(/preserveAspectRatio="none">/g, 'preserveAspectRatio="none"/>')*/
273
+ /*.replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ')
274
+ .replace(/ href=/, ' xlink:href=')
275
+ .replace(/preserveAspectRatio="none">/g, 'preserveAspectRatio="none"/>')*/
305
276
  /* This fails in IE < 8
306
277
  .replace(/([0-9]+)\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight
307
278
  return s2 +'.'+ s3[0];
@@ -316,12 +287,6 @@ extend(Chart.prototype, {
316
287
  .replace(/class=([^" ]+)/g, 'class="$1"')
317
288
  .replace(/ transform /g, ' ')
318
289
  .replace(/:(path|rect)/g, '$1')
319
- .replace(/<img ([^>]*)>/gi, '<image $1 />')
320
- .replace(/<\/image>/g, '') // remove closing tags for images as they'll never have any content
321
- .replace(/<image ([^>]*)([^\/])>/gi, '<image $1$2 />') // closes image tags for firefox
322
- .replace(/width=(\d+)/g, 'width="$1"')
323
- .replace(/height=(\d+)/g, 'height="$1"')
324
- .replace(/hc-svg-href="/g, 'xlink:href="')
325
290
  .replace(/style="([^"]+)"/g, function (s) {
326
291
  return s.toLowerCase();
327
292
  });
@@ -344,7 +309,7 @@ extend(Chart.prototype, {
344
309
  exportChart: function (options, chartOptions) {
345
310
  var form,
346
311
  chart = this,
347
- svg = chart.getSVG(chartOptions);
312
+ svg = chart.getSVG(merge(chart.options.exporting.chartOptions, chartOptions)); // docs
348
313
 
349
314
  // merge the options
350
315
  options = merge(chart.options.exporting, options);
@@ -539,9 +504,6 @@ extend(Chart.prototype, {
539
504
  btnOptions = merge(chart.options.navigation.buttonOptions, options),
540
505
  onclick = btnOptions.onclick,
541
506
  menuItems = btnOptions.menuItems,
542
- /*position = chart.getAlignment(btnOptions),
543
- buttonLeft = position.x,
544
- buttonTop = position.y,*/
545
507
  buttonWidth = btnOptions.width,
546
508
  buttonHeight = btnOptions.height,
547
509
  box,
@@ -555,7 +517,8 @@ extend(Chart.prototype, {
555
517
  symbolAttr = {
556
518
  stroke: btnOptions.symbolStroke,
557
519
  fill: btnOptions.symbolFill
558
- };
520
+ },
521
+ symbolSize = btnOptions.symbolSize || 12;
559
522
 
560
523
  // Keeps references to the button elements
561
524
  if (!chart.exportDivElements) {
@@ -620,8 +583,6 @@ extend(Chart.prototype, {
620
583
  .on('click', revert)
621
584
  .add();
622
585
 
623
- //addEvent(button.element, 'click', revert);
624
-
625
586
  // add the click event
626
587
  if (menuItems) {
627
588
  onclick = function () {
@@ -640,9 +601,10 @@ extend(Chart.prototype, {
640
601
  // the icon
641
602
  symbol = renderer.symbol(
642
603
  btnOptions.symbol,
643
- btnOptions.symbolX,
644
- btnOptions.symbolY,
645
- (btnOptions.symbolSize || 12) / 2
604
+ btnOptions.symbolX - (symbolSize / 2),
605
+ btnOptions.symbolY - (symbolSize / 2),
606
+ symbolSize,
607
+ symbolSize
646
608
  )
647
609
  .align(btnOptions, true)
648
610
  .attr(extend(symbolAttr, {
@@ -686,53 +648,67 @@ extend(Chart.prototype, {
686
648
  }
687
649
  });
688
650
 
651
+ /**
652
+ * Crisp for 1px stroke width, which is default. In the future, consider a smarter,
653
+ * global function.
654
+ */
655
+ function crisp(arr) {
656
+ var i = arr.length;
657
+ while (i--) {
658
+ if (typeof arr[i] === 'number') {
659
+ arr[i] = Math.round(arr[i]) - 0.5;
660
+ }
661
+ }
662
+ return arr;
663
+ }
664
+
689
665
  // Create the export icon
690
- HC.Renderer.prototype.symbols.exportIcon = function (x, y, radius) {
691
- return [
666
+ HC.Renderer.prototype.symbols.exportIcon = function (x, y, width, height) {
667
+ return crisp([
692
668
  M, // the disk
693
- x - radius, y + radius,
669
+ x, y + width,
694
670
  L,
695
- x + radius, y + radius,
696
- x + radius, y + radius * 0.5,
697
- x - radius, y + radius * 0.5,
671
+ x + width, y + height,
672
+ x + width, y + height * 0.8,
673
+ x, y + height * 0.8,
698
674
  'Z',
699
675
  M, // the arrow
700
- x, y + radius * 0.5,
676
+ x + width * 0.5, y + height * 0.8,
701
677
  L,
702
- x - radius * 0.5, y - radius / 3,
703
- x - radius / 6, y - radius / 3,
704
- x - radius / 6, y - radius,
705
- x + radius / 6, y - radius,
706
- x + radius / 6, y - radius / 3,
707
- x + radius * 0.5, y - radius / 3,
678
+ x + width * 0.8, y + height * 0.4,
679
+ x + width * 0.4, y + height * 0.4,
680
+ x + width * 0.4, y,
681
+ x + width * 0.6, y,
682
+ x + width * 0.6, y + height * 0.4,
683
+ x + width * 0.2, y + height * 0.4,
708
684
  'Z'
709
- ];
685
+ ]);
710
686
  };
711
687
  // Create the print icon
712
- HC.Renderer.prototype.symbols.printIcon = function (x, y, radius) {
713
- return [
688
+ HC.Renderer.prototype.symbols.printIcon = function (x, y, width, height) {
689
+ return crisp([
714
690
  M, // the printer
715
- x - radius, y + radius * 0.5,
691
+ x, y + height * 0.7,
716
692
  L,
717
- x + radius, y + radius * 0.5,
718
- x + radius, y - radius / 3,
719
- x - radius, y - radius / 3,
693
+ x + width, y + height * 0.7,
694
+ x + width, y + height * 0.4,
695
+ x, y + height * 0.4,
720
696
  'Z',
721
697
  M, // the upper sheet
722
- x - radius * 0.5, y - radius / 3,
698
+ x + width * 0.2, y + height * 0.4,
723
699
  L,
724
- x - radius * 0.5, y - radius,
725
- x + radius * 0.5, y - radius,
726
- x + radius * 0.5, y - radius / 3,
700
+ x + width * 0.2, y,
701
+ x + width * 0.8, y,
702
+ x + width * 0.8, y + height * 0.4,
727
703
  'Z',
728
704
  M, // the lower sheet
729
- x - radius * 0.5, y + radius * 0.5,
705
+ x + width * 0.2, y + height * 0.7,
730
706
  L,
731
- x - radius * 0.75, y + radius,
732
- x + radius * 0.75, y + radius,
733
- x + radius * 0.5, y + radius * 0.5,
707
+ x, y + height,
708
+ x + width, y + height,
709
+ x + width * 0.8, y + height * 0.7,
734
710
  'Z'
735
- ];
711
+ ]);
736
712
  };
737
713
 
738
714
 
@@ -260,4 +260,4 @@ Highcharts.theme = {
260
260
  };
261
261
 
262
262
  // Apply the theme
263
- var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
263
+ var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
@@ -260,4 +260,4 @@ Highcharts.theme = {
260
260
  };
261
261
 
262
262
  // Apply the theme
263
- var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
263
+ var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
File without changes
@@ -93,4 +93,3 @@ Highcharts.theme = {
93
93
 
94
94
  // Apply the theme
95
95
  var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
96
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highcharts-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.9
4
+ version: 2.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-21 00:00:00.000000000 +01:00
12
+ date: 2012-02-22 00:00:00.000000000 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
17
- requirement: &70222008063260 !ruby/object:Gem::Requirement
17
+ requirement: &70259245170160 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '3.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70222008063260
25
+ version_requirements: *70259245170160
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundler
28
- requirement: &70222008062620 !ruby/object:Gem::Requirement
28
+ requirement: &70259245169440 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70222008062620
36
+ version_requirements: *70259245169440
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rails
39
- requirement: &70222008062160 !ruby/object:Gem::Requirement
39
+ requirement: &70259245168820 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '3.1'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70222008062160
47
+ version_requirements: *70259245168820
48
48
  description: Gem that includes Highcharts (Interactive JavaScript charts for your
49
49
  web projects), in the Rails Asset Pipeline introduced in Rails 3.1
50
50
  email:
@@ -65,6 +65,7 @@ files:
65
65
  - vendor/assets/javascripts/highcharts.js
66
66
  - vendor/assets/javascripts/highcharts/adapters/mootools.js
67
67
  - vendor/assets/javascripts/highcharts/adapters/prototype.js
68
+ - vendor/assets/javascripts/highcharts/modules/canvas-tools.js
68
69
  - vendor/assets/javascripts/highcharts/modules/exporting.js
69
70
  - vendor/assets/javascripts/highcharts/themes/dark-blue.js
70
71
  - vendor/assets/javascripts/highcharts/themes/dark-green.js