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