d3-rails 4.7.4 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a5cc26ee2d2b447d39b554e6a00045f563fb0c5
4
- data.tar.gz: 9377e1e1e4b52d2f89d00a6d68056e68ed2ca915
3
+ metadata.gz: 24f20f9493fba5c1f8305d14092ba0b8b690dec5
4
+ data.tar.gz: 8119c2d1696efb04885477fcd07f55b745fafb19
5
5
  SHA512:
6
- metadata.gz: efaed28155ab17eefaf527a71a7f8b86f801b4592cd77456076b48409543aa6b3f953d9f55a6875f018b3f3e8cea8d0d9feb51e995dd0e2acc6f8c949eb734fa
7
- data.tar.gz: 2d8690201cbdcddf09123f42215f97d7850b653829230d475e0f38f0630423d7a3209cc915243ab93dcb52a05230f20b1c53e24f9f6c615eba6c7b0234b4c6d0
6
+ metadata.gz: 1519b56b9e8de820a076c26f553736a4819d78610049cba2f20ddab0a6ec9c2068884014941b44ae9a89bfe8714d5caee592890baedb287aa9f5f94deb29eb16
7
+ data.tar.gz: e9ac4beb4b6399240df5d0939b1740c7d9d03593780e855e456329c2b74d5a074983ed7940790b63f04601203e06a442990fd700fad7a5dc21ff39bb30e04d4e
@@ -1,3 +1,6 @@
1
+ ## 4.8.0 (15 April 2017)
2
+ # Upgrade D3 to 4.8.0
3
+
1
4
  ## 4.7.0 (28 February 2017)
2
5
  * Upgrade D3 to 4.7.0
3
6
 
data/README.md CHANGED
@@ -8,7 +8,7 @@ d3-rails provides D3 for Rails 3.1 and higher.
8
8
 
9
9
  ## Version
10
10
 
11
- d3-rails comes with version 4.7.4 of D3.js. The d3-rails version will
11
+ d3-rails comes with version 4.8.0 of D3.js. The d3-rails version will
12
12
  always mirror the version of D3. If you need a newer version of
13
13
  d3-rails, see section Development (below).
14
14
 
@@ -1,11 +1,11 @@
1
- // https://d3js.org Version 4.7.4. Copyright 2017 Mike Bostock.
1
+ // https://d3js.org Version 4.8.0. Copyright 2017 Mike Bostock.
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
5
5
  (factory((global.d3 = global.d3 || {})));
6
6
  }(this, (function (exports) { 'use strict';
7
7
 
8
- var version = "4.7.4";
8
+ var version = "4.8.0";
9
9
 
10
10
  var ascending = function(a, b) {
11
11
  return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
@@ -58,11 +58,24 @@ function pair(a, b) {
58
58
  return [a, b];
59
59
  }
60
60
 
61
- var cross = function(a, b, f) {
62
- var na = a.length, nb = b.length, c = new Array(na * nb), ia, ib, ic, va;
63
- if (f == null) f = pair;
64
- for (ia = ic = 0; ia < na; ++ia) for (va = a[ia], ib = 0; ib < nb; ++ib, ++ic) c[ic] = f(va, b[ib]);
65
- return c;
61
+ var cross = function(values0, values1, reduce) {
62
+ var n0 = values0.length,
63
+ n1 = values1.length,
64
+ values = new Array(n0 * n1),
65
+ i0,
66
+ i1,
67
+ i,
68
+ value0;
69
+
70
+ if (reduce == null) reduce = pair;
71
+
72
+ for (i0 = i = 0; i0 < n0; ++i0) {
73
+ for (value0 = values0[i0], i1 = 0; i1 < n1; ++i1, ++i) {
74
+ values[i] = reduce(value0, values1[i1]);
75
+ }
76
+ }
77
+
78
+ return values;
66
79
  };
67
80
 
68
81
  var descending = function(a, b) {
@@ -73,36 +86,36 @@ var number = function(x) {
73
86
  return x === null ? NaN : +x;
74
87
  };
75
88
 
76
- var variance = function(array, f) {
77
- var n = array.length,
89
+ var variance = function(values, valueof) {
90
+ var n = values.length,
78
91
  m = 0,
79
- a,
80
- d,
81
- s = 0,
82
92
  i = -1,
83
- j = 0;
93
+ mean = 0,
94
+ value,
95
+ delta,
96
+ sum = 0;
84
97
 
85
- if (f == null) {
98
+ if (valueof == null) {
86
99
  while (++i < n) {
87
- if (!isNaN(a = number(array[i]))) {
88
- d = a - m;
89
- m += d / ++j;
90
- s += d * (a - m);
100
+ if (!isNaN(value = number(values[i]))) {
101
+ delta = value - mean;
102
+ mean += delta / ++m;
103
+ sum += delta * (value - mean);
91
104
  }
92
105
  }
93
106
  }
94
107
 
95
108
  else {
96
109
  while (++i < n) {
97
- if (!isNaN(a = number(f(array[i], i, array)))) {
98
- d = a - m;
99
- m += d / ++j;
100
- s += d * (a - m);
110
+ if (!isNaN(value = number(valueof(values[i], i, values)))) {
111
+ delta = value - mean;
112
+ mean += delta / ++m;
113
+ sum += delta * (value - mean);
101
114
  }
102
115
  }
103
116
  }
104
117
 
105
- if (j > 1) return s / (j - 1);
118
+ if (m > 1) return sum / (m - 1);
106
119
  };
107
120
 
108
121
  var deviation = function(array, f) {
@@ -110,30 +123,42 @@ var deviation = function(array, f) {
110
123
  return v ? Math.sqrt(v) : v;
111
124
  };
112
125
 
113
- var extent = function(array, f) {
114
- var i = -1,
115
- n = array.length,
116
- a,
117
- b,
118
- c;
119
-
120
- if (f == null) {
121
- while (++i < n) if ((b = array[i]) != null && b >= b) { a = c = b; break; }
122
- while (++i < n) if ((b = array[i]) != null) {
123
- if (a > b) a = b;
124
- if (c < b) c = b;
126
+ var extent = function(values, valueof) {
127
+ var n = values.length,
128
+ i = -1,
129
+ value,
130
+ min,
131
+ max;
132
+
133
+ if (valueof == null) {
134
+ while (++i < n) { // Find the first comparable value.
135
+ if ((value = values[i]) != null && value >= value) {
136
+ min = max = value;
137
+ while (++i < n) { // Compare the remaining values.
138
+ if ((value = values[i]) != null) {
139
+ if (min > value) min = value;
140
+ if (max < value) max = value;
141
+ }
142
+ }
143
+ }
125
144
  }
126
145
  }
127
146
 
128
147
  else {
129
- while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = c = b; break; }
130
- while (++i < n) if ((b = f(array[i], i, array)) != null) {
131
- if (a > b) a = b;
132
- if (c < b) c = b;
148
+ while (++i < n) { // Find the first comparable value.
149
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
150
+ min = max = value;
151
+ while (++i < n) { // Compare the remaining values.
152
+ if ((value = valueof(values[i], i, values)) != null) {
153
+ if (min > value) min = value;
154
+ if (max < value) max = value;
155
+ }
156
+ }
157
+ }
133
158
  }
134
159
  }
135
160
 
136
- return [a, c];
161
+ return [min, max];
137
162
  };
138
163
 
139
164
  var array = Array.prototype;
@@ -170,14 +195,42 @@ var e5 = Math.sqrt(10);
170
195
  var e2 = Math.sqrt(2);
171
196
 
172
197
  var ticks = function(start, stop, count) {
173
- var step = tickStep(start, stop, count);
174
- return sequence(
175
- Math.ceil(start / step) * step,
176
- Math.floor(stop / step) * step + step / 2, // inclusive
177
- step
178
- );
198
+ var reverse = stop < start,
199
+ i = -1,
200
+ n,
201
+ ticks,
202
+ step;
203
+
204
+ if (reverse) n = start, start = stop, stop = n;
205
+
206
+ if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
207
+
208
+ if (step > 0) {
209
+ start = Math.ceil(start / step);
210
+ stop = Math.floor(stop / step);
211
+ ticks = new Array(n = Math.ceil(stop - start + 1));
212
+ while (++i < n) ticks[i] = (start + i) * step;
213
+ } else {
214
+ start = Math.floor(start * step);
215
+ stop = Math.ceil(stop * step);
216
+ ticks = new Array(n = Math.ceil(start - stop + 1));
217
+ while (++i < n) ticks[i] = (start - i) / step;
218
+ }
219
+
220
+ if (reverse) ticks.reverse();
221
+
222
+ return ticks;
179
223
  };
180
224
 
225
+ function tickIncrement(start, stop, count) {
226
+ var step = (stop - start) / Math.max(0, count),
227
+ power = Math.floor(Math.log(step) / Math.LN10),
228
+ error = step / Math.pow(10, power);
229
+ return power >= 0
230
+ ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
231
+ : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
232
+ }
233
+
181
234
  function tickStep(start, stop, count) {
182
235
  var step0 = Math.abs(stop - start) / Math.max(0, count),
183
236
  step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
@@ -213,12 +266,15 @@ var histogram = function() {
213
266
  tz = threshold(values, x0, x1);
214
267
 
215
268
  // Convert number of thresholds into uniform thresholds.
216
- if (!Array.isArray(tz)) tz = ticks(x0, x1, tz);
269
+ if (!Array.isArray(tz)) {
270
+ tz = tickStep(x0, x1, tz);
271
+ tz = sequence(Math.ceil(x0 / tz) * tz, Math.floor(x1 / tz) * tz, tz); // exclusive
272
+ }
217
273
 
218
274
  // Remove any thresholds outside the domain.
219
275
  var m = tz.length;
220
276
  while (tz[0] <= x0) tz.shift(), --m;
221
- while (tz[m - 1] >= x1) tz.pop(), --m;
277
+ while (tz[m - 1] > x1) tz.pop(), --m;
222
278
 
223
279
  var bins = new Array(m + 1),
224
280
  bin;
@@ -256,17 +312,17 @@ var histogram = function() {
256
312
  return histogram;
257
313
  };
258
314
 
259
- var threshold = function(array, p, f) {
260
- if (f == null) f = number;
261
- if (!(n = array.length)) return;
262
- if ((p = +p) <= 0 || n < 2) return +f(array[0], 0, array);
263
- if (p >= 1) return +f(array[n - 1], n - 1, array);
315
+ var threshold = function(values, p, valueof) {
316
+ if (valueof == null) valueof = number;
317
+ if (!(n = values.length)) return;
318
+ if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
319
+ if (p >= 1) return +valueof(values[n - 1], n - 1, values);
264
320
  var n,
265
- h = (n - 1) * p,
266
- i = Math.floor(h),
267
- a = +f(array[i], i, array),
268
- b = +f(array[i + 1], i + 1, array);
269
- return a + (b - a) * (h - i);
321
+ i = (n - 1) * p,
322
+ i0 = Math.floor(i),
323
+ value0 = +valueof(values[i0], i0, values),
324
+ value1 = +valueof(values[i0 + 1], i0 + 1, values);
325
+ return value0 + (value1 - value0) * (i - i0);
270
326
  };
271
327
 
272
328
  var freedmanDiaconis = function(values, min, max) {
@@ -278,55 +334,85 @@ var scott = function(values, min, max) {
278
334
  return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
279
335
  };
280
336
 
281
- var max = function(array, f) {
282
- var i = -1,
283
- n = array.length,
284
- a,
285
- b;
286
-
287
- if (f == null) {
288
- while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; }
289
- while (++i < n) if ((b = array[i]) != null && b > a) a = b;
337
+ var max = function(values, valueof) {
338
+ var n = values.length,
339
+ i = -1,
340
+ value,
341
+ max;
342
+
343
+ if (valueof == null) {
344
+ while (++i < n) { // Find the first comparable value.
345
+ if ((value = values[i]) != null && value >= value) {
346
+ max = value;
347
+ while (++i < n) { // Compare the remaining values.
348
+ if ((value = values[i]) != null && value > max) {
349
+ max = value;
350
+ }
351
+ }
352
+ }
353
+ }
290
354
  }
291
355
 
292
356
  else {
293
- while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = b; break; }
294
- while (++i < n) if ((b = f(array[i], i, array)) != null && b > a) a = b;
357
+ while (++i < n) { // Find the first comparable value.
358
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
359
+ max = value;
360
+ while (++i < n) { // Compare the remaining values.
361
+ if ((value = valueof(values[i], i, values)) != null && value > max) {
362
+ max = value;
363
+ }
364
+ }
365
+ }
366
+ }
295
367
  }
296
368
 
297
- return a;
369
+ return max;
298
370
  };
299
371
 
300
- var mean = function(array, f) {
301
- var s = 0,
302
- n = array.length,
303
- a,
372
+ var mean = function(values, valueof) {
373
+ var n = values.length,
374
+ m = n,
304
375
  i = -1,
305
- j = n;
376
+ value,
377
+ sum = 0;
306
378
 
307
- if (f == null) {
308
- while (++i < n) if (!isNaN(a = number(array[i]))) s += a; else --j;
379
+ if (valueof == null) {
380
+ while (++i < n) {
381
+ if (!isNaN(value = number(values[i]))) sum += value;
382
+ else --m;
383
+ }
309
384
  }
310
385
 
311
386
  else {
312
- while (++i < n) if (!isNaN(a = number(f(array[i], i, array)))) s += a; else --j;
387
+ while (++i < n) {
388
+ if (!isNaN(value = number(valueof(values[i], i, values)))) sum += value;
389
+ else --m;
390
+ }
313
391
  }
314
392
 
315
- if (j) return s / j;
393
+ if (m) return sum / m;
316
394
  };
317
395
 
318
- var median = function(array, f) {
319
- var numbers = [],
320
- n = array.length,
321
- a,
322
- i = -1;
396
+ var median = function(values, valueof) {
397
+ var n = values.length,
398
+ i = -1,
399
+ value,
400
+ numbers = [];
323
401
 
324
- if (f == null) {
325
- while (++i < n) if (!isNaN(a = number(array[i]))) numbers.push(a);
402
+ if (valueof == null) {
403
+ while (++i < n) {
404
+ if (!isNaN(value = number(values[i]))) {
405
+ numbers.push(value);
406
+ }
407
+ }
326
408
  }
327
409
 
328
410
  else {
329
- while (++i < n) if (!isNaN(a = number(f(array[i], i, array)))) numbers.push(a);
411
+ while (++i < n) {
412
+ if (!isNaN(value = number(valueof(values[i], i, values)))) {
413
+ numbers.push(value);
414
+ }
415
+ }
330
416
  }
331
417
 
332
418
  return threshold(numbers.sort(ascending), 0.5);
@@ -354,23 +440,39 @@ var merge = function(arrays) {
354
440
  return merged;
355
441
  };
356
442
 
357
- var min = function(array, f) {
358
- var i = -1,
359
- n = array.length,
360
- a,
361
- b;
362
-
363
- if (f == null) {
364
- while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; }
365
- while (++i < n) if ((b = array[i]) != null && a > b) a = b;
443
+ var min = function(values, valueof) {
444
+ var n = values.length,
445
+ i = -1,
446
+ value,
447
+ min;
448
+
449
+ if (valueof == null) {
450
+ while (++i < n) { // Find the first comparable value.
451
+ if ((value = values[i]) != null && value >= value) {
452
+ min = value;
453
+ while (++i < n) { // Compare the remaining values.
454
+ if ((value = values[i]) != null && min > value) {
455
+ min = value;
456
+ }
457
+ }
458
+ }
459
+ }
366
460
  }
367
461
 
368
462
  else {
369
- while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = b; break; }
370
- while (++i < n) if ((b = f(array[i], i, array)) != null && a > b) a = b;
463
+ while (++i < n) { // Find the first comparable value.
464
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
465
+ min = value;
466
+ while (++i < n) { // Compare the remaining values.
467
+ if ((value = valueof(values[i], i, values)) != null && min > value) {
468
+ min = value;
469
+ }
470
+ }
471
+ }
472
+ }
371
473
  }
372
474
 
373
- return a;
475
+ return min;
374
476
  };
375
477
 
376
478
  var permute = function(array, indexes) {
@@ -379,17 +481,21 @@ var permute = function(array, indexes) {
379
481
  return permutes;
380
482
  };
381
483
 
382
- var scan = function(array, compare) {
383
- if (!(n = array.length)) return;
384
- var i = 0,
385
- n,
484
+ var scan = function(values, compare) {
485
+ if (!(n = values.length)) return;
486
+ var n,
487
+ i = 0,
386
488
  j = 0,
387
489
  xi,
388
- xj = array[j];
490
+ xj = values[j];
389
491
 
390
- if (!compare) compare = ascending;
492
+ if (compare == null) compare = ascending;
391
493
 
392
- while (++i < n) if (compare(xi = array[i], xj) < 0 || compare(xj, xj) !== 0) xj = xi, j = i;
494
+ while (++i < n) {
495
+ if (compare(xi = values[i], xj) < 0 || compare(xj, xj) !== 0) {
496
+ xj = xi, j = i;
497
+ }
498
+ }
393
499
 
394
500
  if (compare(xj, xj) === 0) return j;
395
501
  };
@@ -409,21 +515,25 @@ var shuffle = function(array, i0, i1) {
409
515
  return array;
410
516
  };
411
517
 
412
- var sum = function(array, f) {
413
- var s = 0,
414
- n = array.length,
415
- a,
416
- i = -1;
518
+ var sum = function(values, valueof) {
519
+ var n = values.length,
520
+ i = -1,
521
+ value,
522
+ sum = 0;
417
523
 
418
- if (f == null) {
419
- while (++i < n) if (a = +array[i]) s += a; // Note: zero and null are equivalent.
524
+ if (valueof == null) {
525
+ while (++i < n) {
526
+ if (value = +values[i]) sum += value; // Note: zero and null are equivalent.
527
+ }
420
528
  }
421
529
 
422
530
  else {
423
- while (++i < n) if (a = +f(array[i], i, array)) s += a;
531
+ while (++i < n) {
532
+ if (value = +valueof(values[i], i, values)) sum += value;
533
+ }
424
534
  }
425
535
 
426
- return s;
536
+ return sum;
427
537
  };
428
538
 
429
539
  var transpose = function(matrix) {
@@ -6405,7 +6515,8 @@ var formatLocale = function(locale) {
6405
6515
  var group = locale.grouping && locale.thousands ? formatGroup(locale.grouping, locale.thousands) : identity$3,
6406
6516
  currency = locale.currency,
6407
6517
  decimal = locale.decimal,
6408
- numerals = locale.numerals ? formatNumerals(locale.numerals) : identity$3;
6518
+ numerals = locale.numerals ? formatNumerals(locale.numerals) : identity$3,
6519
+ percent = locale.percent || "%";
6409
6520
 
6410
6521
  function newFormat(specifier) {
6411
6522
  specifier = formatSpecifier(specifier);
@@ -6423,7 +6534,7 @@ var formatLocale = function(locale) {
6423
6534
  // Compute the prefix and suffix.
6424
6535
  // For SI-prefix, the suffix is lazily computed.
6425
6536
  var prefix = symbol === "$" ? currency[0] : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
6426
- suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? "%" : "";
6537
+ suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? percent : "";
6427
6538
 
6428
6539
  // What format function should we use?
6429
6540
  // Is this an integer type?
@@ -16203,6 +16314,7 @@ exports.scan = scan;
16203
16314
  exports.shuffle = shuffle;
16204
16315
  exports.sum = sum;
16205
16316
  exports.ticks = ticks;
16317
+ exports.tickIncrement = tickIncrement;
16206
16318
  exports.tickStep = tickStep;
16207
16319
  exports.transpose = transpose;
16208
16320
  exports.variance = variance;