highcharts-js-rails 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v0.1.10 (2012-09-06) ##
2
+
3
+ * Update Highcharts to 2.3.2.
4
+ * Take new parts of the API into account:
5
+ * PlotOptions for arearange, areasplinerange, columnrange, and gauge.
6
+
1
7
  ## v0.1.9 (2012-06-21) ##
2
8
 
3
9
  * Update Highcharts to 2.2.5.
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'highcharts-js-rails'
6
- s.version = '0.1.9'
6
+ s.version = '0.1.10'
7
7
  s.authors = ['Alex Robbin']
8
8
  s.email = ['agrobbin@gmail.com']
9
9
  s.homepage = 'https://github.com/agrobbin/highcharts-js-rails'
@@ -5,8 +5,10 @@ class Highcharts
5
5
  def initialize(opts = {})
6
6
  @suboptions = {
7
7
  :dataLabels => 'Labels',
8
+ :dial => 'Base',
8
9
  :events => 'PlotOptions::PlotType::Events',
9
10
  :marker => 'PlotOptions::PlotType::Marker',
11
+ :pivot => 'Base',
10
12
  :point => 'Point',
11
13
  :states => 'PlotOptions::PlotType::States'
12
14
  }
@@ -4,9 +4,13 @@ class Highcharts
4
4
  def initialize(opts = {})
5
5
  @suboptions = {
6
6
  :area => 'PlotOptions::PlotType',
7
+ :arearange => 'PlotOptions::PlotType',
7
8
  :areaspline => 'PlotOptions::PlotType',
9
+ :areasplinerange => 'PlotOptions::PlotType',
8
10
  :bar => 'PlotOptions::PlotType',
9
11
  :column => 'PlotOptions::PlotType',
12
+ :columnrange => 'PlotOptions::PlotType',
13
+ :gauge => 'PlotOptions::PlotType',
10
14
  :line => 'PlotOptions::PlotType',
11
15
  :pie => 'PlotOptions::PlotType',
12
16
  :series => 'PlotOptions::PlotType',
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v2.2.5 (2012-06-08)
2
+ * @license Highcharts JS v2.3.2 (2012-08-31)
3
3
  * MooTools adapter
4
4
  *
5
5
  * (c) 2010-2011 Torstein Hønsi
@@ -78,8 +78,9 @@ win.HighchartsAdapter = {
78
78
 
79
79
  // This currently works for getting inner width and height. If adding
80
80
  // more methods later, we need a conditional implementation for each.
81
- return $(el).getStyle(method).toInt();
82
-
81
+ if (method === 'width' || method === 'height') {
82
+ return parseInt($(el).getStyle(method), 10);
83
+ }
83
84
  },
84
85
 
85
86
  /**
@@ -181,6 +182,13 @@ win.HighchartsAdapter = {
181
182
  grep: function (arr, fn) {
182
183
  return arr.filter(fn);
183
184
  },
185
+
186
+ /**
187
+ * Return the index of an item in an array, or -1 if not matched
188
+ */
189
+ inArray: function (item, arr, from) {
190
+ return arr.indexOf(item, from);
191
+ },
184
192
 
185
193
  /**
186
194
  * Deep merge two objects and return a third
@@ -303,9 +311,7 @@ win.HighchartsAdapter = {
303
311
  * Set back e.pageX and e.pageY that MooTools has abstracted away
304
312
  */
305
313
  washMouseEvent: function (e) {
306
- e.pageX = e.page.x;
307
- e.pageY = e.page.y;
308
- return e;
314
+ return e.event || e;
309
315
  },
310
316
 
311
317
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v2.2.5 (2012-06-08)
2
+ * @license Highcharts JS v2.3.2 (2012-08-31)
3
3
  * Prototype adapter
4
4
  *
5
5
  * @author Michael Nelson, Torstein Hønsi.
@@ -200,6 +200,10 @@ return {
200
200
  each: function (arr, fn) {
201
201
  $A(arr).each(fn);
202
202
  },
203
+
204
+ inArray: function (item, arr) {
205
+ return arr.indexOf(item);
206
+ },
203
207
 
204
208
  /**
205
209
  * Get the cumulative offset relative to the top left of the page. This method, unlike its
@@ -2908,7 +2908,7 @@ if (CanvasRenderingContext2D) {
2908
2908
  });
2909
2909
  }
2910
2910
  }/**
2911
- * @license Highcharts JS v2.2.5 (2012-06-08)
2911
+ * @license Highcharts JS v2.3.2 (2012-08-31)
2912
2912
  * CanVGRenderer Extension module
2913
2913
  *
2914
2914
  * (c) 2011-2012 Torstein Hønsi, Erik Olsson
@@ -0,0 +1,277 @@
1
+ /**
2
+ * @license Data plugin for Highcharts v0.1
3
+ *
4
+ * (c) 2012 Torstein Hønsi
5
+ *
6
+ * License: www.highcharts.com/license
7
+ */
8
+
9
+ /*
10
+ * Demo: http://jsfiddle.net/highcharts/SnLFj/
11
+ */
12
+
13
+ (function (Highcharts) {
14
+
15
+ // Utilities
16
+ var each = Highcharts.each;
17
+
18
+
19
+ // The Data constructor
20
+ var Data = function (options) {
21
+ this.init(options);
22
+ };
23
+
24
+ // Set the prototype properties
25
+ Highcharts.extend(Data.prototype, {
26
+
27
+ /**
28
+ * Initialize the Data object with the given options
29
+ */
30
+ init: function (options) {
31
+ this.options = options;
32
+ this.columns = [];
33
+
34
+
35
+ // Parse a CSV string if options.csv is given
36
+ this.parseCSV();
37
+
38
+ // Parse a HTML table if options.table is given
39
+ this.parseTable();
40
+
41
+ // Interpret the values into right types
42
+ this.parseTypes();
43
+
44
+ // Use first row for series names?
45
+ this.findHeaderRow();
46
+
47
+ // Handle columns if a handleColumns callback is given
48
+ this.parsed();
49
+
50
+ // Complete if a complete callback is given
51
+ this.complete();
52
+
53
+ },
54
+
55
+ /**
56
+ * Parse a CSV input string
57
+ */
58
+ parseCSV: function () {
59
+ var options = this.options,
60
+ csv = options.csv,
61
+ columns = this.columns,
62
+ startRow = options.startRow || 0,
63
+ endRow = options.endRow || Number.MAX_VALUE,
64
+ startColumn = options.startColumn || 0,
65
+ endColumn = options.endColumn || Number.MAX_VALUE,
66
+ lines;
67
+
68
+ if (csv) {
69
+ lines = csv.split(options.lineDelimiter || '\n');
70
+
71
+ each(lines, function (line, rowNo) {
72
+ if (rowNo >= startRow && rowNo <= endRow) {
73
+ var items = line.split(options.itemDelimiter || ',');
74
+ each(items, function (item, colNo) {
75
+ if (colNo >= startColumn && colNo <= endColumn) {
76
+ if (!columns[colNo - startColumn]) {
77
+ columns[colNo - startColumn] = [];
78
+ }
79
+
80
+ columns[colNo - startColumn][rowNo - startRow] = item;
81
+ }
82
+ });
83
+ }
84
+ });
85
+ }
86
+ },
87
+
88
+ /**
89
+ * Parse a HTML table
90
+ */
91
+ parseTable: function () {
92
+ var options = this.options,
93
+ table = options.table,
94
+ columns = this.columns,
95
+ startRow = options.startRow || 0,
96
+ endRow = options.endRow || Number.MAX_VALUE,
97
+ startColumn = options.startColumn || 0,
98
+ endColumn = options.endColumn || Number.MAX_VALUE,
99
+ colNo;
100
+
101
+ if (table) {
102
+
103
+ if (typeof table === 'string') {
104
+ table = document.getElementById(table);
105
+ }
106
+
107
+ each(table.getElementsByTagName('tr'), function (tr, rowNo) {
108
+ colNo = 0;
109
+ if (rowNo >= startRow && rowNo <= endRow) {
110
+ each(tr.childNodes, function (item) {
111
+ if ((item.tagName === 'TD' || item.tagName === 'TH') && colNo >= startColumn && colNo <= endColumn) {
112
+ if (!columns[colNo]) {
113
+ columns[colNo] = [];
114
+ }
115
+ columns[colNo][rowNo - startRow] = item.innerHTML;
116
+
117
+ colNo += 1;
118
+ }
119
+ });
120
+ }
121
+ });
122
+ }
123
+ },
124
+
125
+ /**
126
+ * Find the header row. For now, we just check whether the first row contains
127
+ * numbers or strings. Later we could loop down and find the first row with
128
+ * numbers.
129
+ */
130
+ findHeaderRow: function () {
131
+ var headerRow = 0;
132
+ each(this.columns, function (column) {
133
+ if (typeof column[0] !== 'string') {
134
+ headerRow = null;
135
+ }
136
+ });
137
+ this.headerRow = 0;
138
+ },
139
+
140
+ /**
141
+ * Trim a string from whitespace
142
+ */
143
+ trim: function (str) {
144
+ return str.replace(/^\s+|\s+$/g, '');
145
+ },
146
+
147
+ /**
148
+ * Parse numeric cells in to number types and date types in to true dates.
149
+ * @param {Object} columns
150
+ */
151
+ parseTypes: function () {
152
+ var columns = this.columns,
153
+ col = columns.length,
154
+ row,
155
+ val,
156
+ floatVal,
157
+ trimVal,
158
+ dateVal;
159
+
160
+ while (col--) {
161
+ row = columns[col].length;
162
+ while (row--) {
163
+ val = columns[col][row];
164
+ floatVal = parseFloat(val);
165
+ trimVal = this.trim(val);
166
+ /*jslint eqeq: true*/
167
+ if (trimVal == floatVal) { // is numeric
168
+ /*jslint eqeq: false*/
169
+ columns[col][row] = floatVal;
170
+
171
+ // If the number is greater than milliseconds in a year, assume datetime
172
+ if (floatVal > 365 * 24 * 3600 * 1000) {
173
+ columns[col].isDatetime = true;
174
+ } else {
175
+ columns[col].isNumeric = true;
176
+ }
177
+
178
+ } else { // string, continue to determine if it is a date string or really a string
179
+ dateVal = Date.parse(val);
180
+
181
+ if (col === 0 && typeof dateVal === 'number' && !isNaN(dateVal)) { // is date
182
+ columns[col][row] = dateVal;
183
+ columns[col].isDatetime = true;
184
+
185
+ } else { // string
186
+ columns[col][row] = trimVal;
187
+ }
188
+ }
189
+
190
+ }
191
+ }
192
+ },
193
+
194
+ parsed: function () {
195
+ if (this.options.parsed) {
196
+ this.options.parsed.call(this, this.columns);
197
+ }
198
+ },
199
+
200
+ /**
201
+ * If a complete callback function is provided in the options, interpret the
202
+ * columns into a Highcharts options object.
203
+ */
204
+ complete: function () {
205
+
206
+ var columns = this.columns,
207
+ hasXData,
208
+ categories,
209
+ firstCol,
210
+ type,
211
+ options = this.options,
212
+ series,
213
+ data,
214
+ name,
215
+ i,
216
+ j;
217
+
218
+
219
+ if (options.complete) {
220
+
221
+ // Use first column for X data or categories?
222
+ if (columns.length > 1) {
223
+ firstCol = columns.shift();
224
+ if (this.headerRow === 0) {
225
+ firstCol.shift(); // remove the first cell
226
+ }
227
+
228
+ // Use the first column for categories or X values
229
+ hasXData = firstCol.isNumeric || firstCol.isDatetime;
230
+ if (!hasXData) { // means type is neither datetime nor linear
231
+ categories = firstCol;
232
+ }
233
+
234
+ if (firstCol.isDatetime) {
235
+ type = 'datetime';
236
+ }
237
+ }
238
+
239
+ // Use the next columns for series
240
+ series = [];
241
+ for (i = 0; i < columns.length; i++) {
242
+ if (this.headerRow === 0) {
243
+ name = columns[i].shift();
244
+ }
245
+ data = [];
246
+ for (j = 0; j < columns[i].length; j++) {
247
+ data[j] = columns[i][j] !== undefined ?
248
+ (hasXData ?
249
+ [firstCol[j], columns[i][j]] :
250
+ columns[i][j]
251
+ ) :
252
+ null;
253
+ }
254
+ series[i] = {
255
+ name: name,
256
+ data: data
257
+ };
258
+ }
259
+
260
+ // Do the callback
261
+ options.complete({
262
+ xAxis: {
263
+ categories: categories,
264
+ type: type
265
+ },
266
+ series: series
267
+ });
268
+ }
269
+ }
270
+ });
271
+
272
+ // Register the Data prototype and data function on Highcharts
273
+ Highcharts.Data = Data;
274
+ Highcharts.data = function (options) {
275
+ return new Data(options);
276
+ };
277
+ }(Highcharts));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v2.2.5 (2012-06-08)
2
+ * @license Highcharts JS v2.3.2 (2012-08-31)
3
3
  * Exporting module
4
4
  *
5
5
  * (c) 2010-2011 Torstein Hønsi
@@ -8,7 +8,7 @@ Highcharts.theme = {
8
8
  "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
9
9
  chart: {
10
10
  backgroundColor: {
11
- linearGradient: [0, 0, 250, 500],
11
+ linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
12
12
  stops: [
13
13
  [0, 'rgb(48, 48, 96)'],
14
14
  [1, 'rgb(0, 0, 0)']
@@ -133,7 +133,7 @@ Highcharts.theme = {
133
133
  navigation: {
134
134
  buttonOptions: {
135
135
  backgroundColor: {
136
- linearGradient: [0, 0, 0, 20],
136
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
137
137
  stops: [
138
138
  [0.4, '#606060'],
139
139
  [0.6, '#333333']
@@ -160,7 +160,7 @@ Highcharts.theme = {
160
160
  rangeSelector: {
161
161
  buttonTheme: {
162
162
  fill: {
163
- linearGradient: [0, 0, 0, 20],
163
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
164
164
  stops: [
165
165
  [0.4, '#888'],
166
166
  [0.6, '#555']
@@ -174,7 +174,7 @@ Highcharts.theme = {
174
174
  states: {
175
175
  hover: {
176
176
  fill: {
177
- linearGradient: [0, 0, 0, 20],
177
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
178
178
  stops: [
179
179
  [0.4, '#BBB'],
180
180
  [0.6, '#888']
@@ -187,7 +187,7 @@ Highcharts.theme = {
187
187
  },
188
188
  select: {
189
189
  fill: {
190
- linearGradient: [0, 0, 0, 20],
190
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
191
191
  stops: [
192
192
  [0.1, '#000'],
193
193
  [0.3, '#333']
@@ -224,7 +224,7 @@ Highcharts.theme = {
224
224
 
225
225
  scrollbar: {
226
226
  barBackgroundColor: {
227
- linearGradient: [0, 0, 0, 20],
227
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
228
228
  stops: [
229
229
  [0.4, '#888'],
230
230
  [0.6, '#555']
@@ -233,7 +233,7 @@ Highcharts.theme = {
233
233
  barBorderColor: '#CCC',
234
234
  buttonArrowColor: '#CCC',
235
235
  buttonBackgroundColor: {
236
- linearGradient: [0, 0, 0, 20],
236
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
237
237
  stops: [
238
238
  [0.4, '#888'],
239
239
  [0.6, '#555']
@@ -242,7 +242,7 @@ Highcharts.theme = {
242
242
  buttonBorderColor: '#CCC',
243
243
  rifleColor: '#FFF',
244
244
  trackBackgroundColor: {
245
- linearGradient: [0, 0, 0, 10],
245
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
246
246
  stops: [
247
247
  [0, '#000'],
248
248
  [1, '#333']
@@ -133,7 +133,7 @@ Highcharts.theme = {
133
133
  navigation: {
134
134
  buttonOptions: {
135
135
  backgroundColor: {
136
- linearGradient: [0, 0, 0, 20],
136
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
137
137
  stops: [
138
138
  [0.4, '#606060'],
139
139
  [0.6, '#333333']
@@ -160,7 +160,7 @@ Highcharts.theme = {
160
160
  rangeSelector: {
161
161
  buttonTheme: {
162
162
  fill: {
163
- linearGradient: [0, 0, 0, 20],
163
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
164
164
  stops: [
165
165
  [0.4, '#888'],
166
166
  [0.6, '#555']
@@ -174,7 +174,7 @@ Highcharts.theme = {
174
174
  states: {
175
175
  hover: {
176
176
  fill: {
177
- linearGradient: [0, 0, 0, 20],
177
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
178
178
  stops: [
179
179
  [0.4, '#BBB'],
180
180
  [0.6, '#888']
@@ -187,7 +187,7 @@ Highcharts.theme = {
187
187
  },
188
188
  select: {
189
189
  fill: {
190
- linearGradient: [0, 0, 0, 20],
190
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
191
191
  stops: [
192
192
  [0.1, '#000'],
193
193
  [0.3, '#333']
@@ -224,7 +224,7 @@ Highcharts.theme = {
224
224
 
225
225
  scrollbar: {
226
226
  barBackgroundColor: {
227
- linearGradient: [0, 0, 0, 20],
227
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
228
228
  stops: [
229
229
  [0.4, '#888'],
230
230
  [0.6, '#555']
@@ -233,7 +233,7 @@ Highcharts.theme = {
233
233
  barBorderColor: '#CCC',
234
234
  buttonArrowColor: '#CCC',
235
235
  buttonBackgroundColor: {
236
- linearGradient: [0, 0, 0, 20],
236
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
237
237
  stops: [
238
238
  [0.4, '#888'],
239
239
  [0.6, '#555']
@@ -242,7 +242,7 @@ Highcharts.theme = {
242
242
  buttonBorderColor: '#CCC',
243
243
  rifleColor: '#FFF',
244
244
  trackBackgroundColor: {
245
- linearGradient: [0, 0, 0, 10],
245
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
246
246
  stops: [
247
247
  [0, '#000'],
248
248
  [1, '#333']
@@ -8,7 +8,7 @@ Highcharts.theme = {
8
8
  "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
9
9
  chart: {
10
10
  backgroundColor: {
11
- linearGradient: [0, 0, 0, 400],
11
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
12
12
  stops: [
13
13
  [0, 'rgb(96, 96, 96)'],
14
14
  [1, 'rgb(16, 16, 16)']
@@ -86,7 +86,7 @@ Highcharts.theme = {
86
86
  },
87
87
  tooltip: {
88
88
  backgroundColor: {
89
- linearGradient: [0, 0, 0, 50],
89
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
90
90
  stops: [
91
91
  [0, 'rgba(96, 96, 96, .8)'],
92
92
  [1, 'rgba(16, 16, 16, .8)']
@@ -132,7 +132,7 @@ Highcharts.theme = {
132
132
  navigation: {
133
133
  buttonOptions: {
134
134
  backgroundColor: {
135
- linearGradient: [0, 0, 0, 20],
135
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
136
136
  stops: [
137
137
  [0.4, '#606060'],
138
138
  [0.6, '#333333']
@@ -159,7 +159,7 @@ Highcharts.theme = {
159
159
  rangeSelector: {
160
160
  buttonTheme: {
161
161
  fill: {
162
- linearGradient: [0, 0, 0, 20],
162
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
163
163
  stops: [
164
164
  [0.4, '#888'],
165
165
  [0.6, '#555']
@@ -173,7 +173,7 @@ Highcharts.theme = {
173
173
  states: {
174
174
  hover: {
175
175
  fill: {
176
- linearGradient: [0, 0, 0, 20],
176
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
177
177
  stops: [
178
178
  [0.4, '#BBB'],
179
179
  [0.6, '#888']
@@ -186,7 +186,7 @@ Highcharts.theme = {
186
186
  },
187
187
  select: {
188
188
  fill: {
189
- linearGradient: [0, 0, 0, 20],
189
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
190
190
  stops: [
191
191
  [0.1, '#000'],
192
192
  [0.3, '#333']
@@ -223,7 +223,7 @@ Highcharts.theme = {
223
223
 
224
224
  scrollbar: {
225
225
  barBackgroundColor: {
226
- linearGradient: [0, 0, 0, 20],
226
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
227
227
  stops: [
228
228
  [0.4, '#888'],
229
229
  [0.6, '#555']
@@ -232,7 +232,7 @@ Highcharts.theme = {
232
232
  barBorderColor: '#CCC',
233
233
  buttonArrowColor: '#CCC',
234
234
  buttonBackgroundColor: {
235
- linearGradient: [0, 0, 0, 20],
235
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
236
236
  stops: [
237
237
  [0.4, '#888'],
238
238
  [0.6, '#555']
@@ -241,7 +241,7 @@ Highcharts.theme = {
241
241
  buttonBorderColor: '#CCC',
242
242
  rifleColor: '#FFF',
243
243
  trackBackgroundColor: {
244
- linearGradient: [0, 0, 0, 10],
244
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
245
245
  stops: [
246
246
  [0, '#000'],
247
247
  [1, '#333']
@@ -7,7 +7,7 @@ Highcharts.theme = {
7
7
  colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
8
8
  chart: {
9
9
  backgroundColor: {
10
- linearGradient: [0, 0, 500, 500],
10
+ linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
11
11
  stops: [
12
12
  [0, 'rgb(255, 255, 255)'],
13
13
  [1, 'rgb(240, 240, 255)']