@jrkasprzyk/parcoord-es 3.0.1 → 3.0.2

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.
package/dist/parcoords.js CHANGED
@@ -261,10 +261,12 @@
261
261
  }
262
262
  var brushRangeMax = config.dimensions[axis].type === 'string' ? config.dimensions[axis].yscale.range()[config.dimensions[axis].yscale.range().length - 1] : config.dimensions[axis].yscale.range()[0];
263
263
  var _brush = d3Brush.brushY(_selector).extent([[-15, 0], [15, brushRangeMax]]);
264
- var convertBrushArguments = function convertBrushArguments(args) {
265
- var args_array = Array.prototype.slice.call(args);
266
- var axis = args_array[0];
267
- var raw = d3Brush.brushSelection(args_array[2][0]) || [];
264
+
265
+ // d3 v6+ invokes listeners as (event, datum); the v5 (datum, index, nodes)
266
+ // layout this used to slice out of `arguments` no longer exists. The axis name
267
+ // is already in scope above, and the node is the listener's `this`.
268
+ var convertBrushArguments = function convertBrushArguments(node) {
269
+ var raw = d3Brush.brushSelection(node) || [];
268
270
 
269
271
  // handle hidden axes which will not have a yscale
270
272
  var yscale = null;
@@ -275,8 +277,8 @@
275
277
  // ordinal scales do not have invert
276
278
  var scaled = invertByScale(raw, yscale);
277
279
  return {
278
- axis: args_array[0],
279
- node: args_array[2][0],
280
+ axis: axis,
281
+ node: node,
280
282
  selection: {
281
283
  raw: raw,
282
284
  scaled: scaled
@@ -284,17 +286,19 @@
284
286
  };
285
287
  };
286
288
  _brush.on('start', function (event) {
287
- if (event.sourceEvent !== null) {
288
- events.call('brushstart', pc, config.brushed, convertBrushArguments(arguments));
289
+ // d3 v6+ leaves sourceEvent undefined for a programmatic brush.move,
290
+ // where v5 set it to null; `!=` catches both.
291
+ if (event.sourceEvent != null) {
292
+ events.call('brushstart', pc, config.brushed, convertBrushArguments(this));
289
293
  if (typeof event.sourceEvent.stopPropagation === 'function') {
290
294
  event.sourceEvent.stopPropagation();
291
295
  }
292
296
  }
293
297
  }).on('brush', function () {
294
- brushUpdated$1(config, pc, events, convertBrushArguments(arguments))(selected$4(state, config, brushGroup)());
298
+ brushUpdated$1(config, pc, events, convertBrushArguments(this))(selected$4(state, config, brushGroup)());
295
299
  }).on('end', function () {
296
300
  brushUpdated$1(config, pc, events)(selected$4(state, config, brushGroup)());
297
- events.call('brushend', pc, config.brushed, convertBrushArguments(arguments));
301
+ events.call('brushend', pc, config.brushed, convertBrushArguments(this));
298
302
  });
299
303
  state.brushes[axis] = _brush;
300
304
  state.brushNodes[axis] = _selector.node();
@@ -711,7 +715,9 @@
711
715
  }];
712
716
  }
713
717
  brush.on('start', function (event) {
714
- if (event.sourceEvent !== null) {
718
+ // d3 v6+ leaves sourceEvent undefined for a programmatic brush.move,
719
+ // where v5 set it to null; `!=` catches both.
720
+ if (event.sourceEvent != null) {
715
721
  events.call('brushstart', pc, config.brushed);
716
722
  if (typeof event.sourceEvent.stopPropagation === 'function') {
717
723
  event.sourceEvent.stopPropagation();
@@ -2019,11 +2025,16 @@
2019
2025
  if (config.dimensions[d] !== undefined) {
2020
2026
  config.dimensions[d]['brush'] = d3Brush.brushY(d3Selection.select(this)).extent([[-15, 0], [15, config.dimensions[d].yscale.range()[0]]]);
2021
2027
  d3Selection.select(this).call(config.dimensions[d]['brush'].on('start', function (event) {
2022
- if (event.sourceEvent !== null && !event.sourceEvent.ctrlKey) {
2028
+ // `!=` also catches the undefined d3 v6+ uses for a
2029
+ // programmatic brush.move, which `!== null` let through
2030
+ // straight into the .ctrlKey dereference below.
2031
+ if (event.sourceEvent != null && !event.sourceEvent.ctrlKey) {
2023
2032
  pc.brushReset();
2024
2033
  }
2025
2034
  }).on('brush', function (event) {
2026
- if (!event.sourceEvent.ctrlKey) {
2035
+ // A programmatic brush.move leaves sourceEvent undefined in
2036
+ // d3 v6+; treat that as "no Ctrl key" rather than dereferencing.
2037
+ if (!(event.sourceEvent && event.sourceEvent.ctrlKey)) {
2027
2038
  pc.brush();
2028
2039
  }
2029
2040
  }).on('end', function (event) {
@@ -2031,7 +2042,7 @@
2031
2042
  // store important brush information and
2032
2043
  // the html element of the selection,
2033
2044
  // to make a dummy selection element
2034
- if (event.sourceEvent.ctrlKey) {
2045
+ if (event.sourceEvent && event.sourceEvent.ctrlKey) {
2035
2046
  var html = d3Selection.select(this).select('.selection').nodes()[0].outerHTML;
2036
2047
  html = html.replace('class="selection"', 'class="selection dummy' + ' selection-' + config.brushes.length + '"');
2037
2048
  var dat = d3Selection.select(this).nodes()[0].__data__;
@@ -3739,7 +3750,7 @@
3739
3750
  };
3740
3751
  };
3741
3752
 
3742
- const version = "3.0.1";
3753
+ const version = "3.0.2";
3743
3754
 
3744
3755
  var DefaultConfig = {
3745
3756
  data: [],