@jrkasprzyk/parcoord-es 3.0.0 → 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/README.md CHANGED
@@ -1,6 +1,16 @@
1
- # parcoords-es
1
+ # @jrkasprzyk/parcoord-es
2
2
 
3
- ES6 module of Syntagmatic's [Parallel Coordinates](https://github.com/syntagmatic/parallel-coordinates) (aka. parcoords). This library is completely based on D3 V5 API.
3
+ [![npm version](https://img.shields.io/npm/v/%40jrkasprzyk%2Fparcoord-es.svg)](https://www.npmjs.com/package/@jrkasprzyk/parcoord-es)
4
+
5
+ A maintained fork of [BigFatDog/parcoords-es](https://github.com/BigFatDog/parcoords-es), an ES6 module of Syntagmatic's [Parallel Coordinates](https://github.com/syntagmatic/parallel-coordinates) (aka. parcoords). This library is completely based on the D3 V7 API.
6
+
7
+ ## About this fork
8
+
9
+ The upstream `parcoord-es` package is built on D3 V5 and is no longer actively maintained. This fork:
10
+
11
+ * Migrates the library to **D3 V7** modules
12
+ * Updates the build toolchain (Rollup 4, Babel 7, ESLint 8, Mocha 11) and resolves all known dependency vulnerabilities
13
+ * Is published to npm as [`@jrkasprzyk/parcoord-es`](https://www.npmjs.com/package/@jrkasprzyk/parcoord-es)
4
14
 
5
15
 
6
16
  ## Features
@@ -20,13 +30,13 @@ This section only lists api that are <b>deviated</b> from the original parallel
20
30
 
21
31
  <a name="parcoords_brush_extents" href="#parcoords_brush_extents">#</a> parcoords.<b>brushExtents</b>(extents) supports 1D multi brushes:
22
32
 
23
- 1D brush [<>](https://github.com/BigFatDog/parcoords-es/blob/master/demo/setterForBrushes.html "Source")
33
+ 1D brush [<>](https://github.com/jrkasprzyk/parcoords-es/blob/master/demo/setterForBrushes.html "Source")
24
34
  ```javascript
25
35
  .brushMode("1D-axes")
26
36
  .brushExtents({"2": [3,4]});
27
37
  ```
28
38
 
29
- 1D multi brush [<>](https://github.com/BigFatDog/parcoords-es/blob/master/demo/setterForMultiBrushes.html "Source")
39
+ 1D multi brush [<>](https://github.com/jrkasprzyk/parcoords-es/blob/master/demo/setterForMultiBrushes.html "Source")
30
40
  ```javascript
31
41
  .brushMode("1D-axes-multi")
32
42
  .brushExtents({"2": [[3,4], [6,8], [10, 14]]});
@@ -56,7 +66,7 @@ const data = [...];
56
66
  const pc = ParCoords().data(data)...;
57
67
  parcoords.mark(data.filter(d => d.volume > 10));
58
68
  ```
59
- Please refer to [marking demo](https://github.com/BigFatDog/parcoords-es/blob/develop/demo/marking.html "Source") for details
69
+ Please refer to [marking demo](https://github.com/jrkasprzyk/parcoords-es/blob/master/demo/marking.html "Source") for details
60
70
 
61
71
  <a name="parcoords_unmark" href="#parcoords_unmark">#</a> parcoords.<b>unmark</b>()
62
72
  clears all permanently highlighted data that is added by <a href="#parcoords_marking">mark([values])</a>
@@ -76,27 +86,27 @@ parcoords.on('brushstart', function(brushed, args){
76
86
  } = args;
77
87
  })
78
88
  ```
79
- Please refer to [brushing with arguments demo](https://github.com/BigFatDog/parcoords-es/blob/develop/demo/brush-with-arguments.html "Source") for details
89
+ Please refer to [brushing with arguments demo](https://github.com/jrkasprzyk/parcoords-es/blob/master/demo/brush-with-arguments.html "Source") for details
80
90
 
81
91
  ## Usage
82
92
 
83
93
  ### ES6
84
94
  1. Install library in your project
85
95
  ```
86
- npm install parcoord-es --save
96
+ npm install @jrkasprzyk/parcoord-es --save
87
97
  ```
88
98
 
89
99
  2. import module
90
100
 
91
101
  ```
92
- import 'parcoord-es/dist/parcoords.css';
93
- import ParCoords from 'parcoord-es';
102
+ import '@jrkasprzyk/parcoord-es/dist/parcoords.css';
103
+ import ParCoords from '@jrkasprzyk/parcoord-es';
94
104
 
95
105
  const chart = ParCoords()....
96
106
  ```
97
107
  ### Standalone
98
108
 
99
- parcoords.standalone.js contains all dependencies and can be used directly in your html page. Please note that only essential D3 V5 modules are bundled, your global namespace won't be polluted.
109
+ parcoords.standalone.js contains all dependencies and can be used directly in your html page. Please note that only essential D3 V7 modules are bundled, your global namespace won't be polluted.
100
110
  ```
101
111
  <link rel="stylesheet" type="text/css" href="./parcoords.css">
102
112
  <script src="./parcoords.standalone.js"></script>
@@ -104,8 +114,6 @@ parcoords.standalone.js contains all dependencies and can be used directly in yo
104
114
  var parcoords = ParCoords()("#example")
105
115
  ```
106
116
 
107
- You are free to use either D3 V3 or D3 V5 in your html. demo/superformula.html demonstrates how to use parcoords-es with d3 V3.
108
-
109
117
  ## Development
110
118
 
111
119
  Follow this instruction to setup development environment for parcoords-es
@@ -142,7 +150,7 @@ npm run test:cover
142
150
 
143
151
  ## Built With
144
152
 
145
- * [D3 V5](https://d3js.org/) - D3 modules are used
153
+ * [D3 V7](https://d3js.org/) - D3 modules are used
146
154
  * [Rollup](https://github.com/rollup/rollup) - Module bundler
147
155
 
148
156
 
@@ -151,7 +159,7 @@ npm run test:cover
151
159
  This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
152
160
 
153
161
  ## Contributors
154
- This project gets supports from open-source community. Many thanks to our [contributors](https://github.com/BigFatDog/parcoords-es/graphs/contributors)
162
+ This project gets supports from open-source community. Many thanks to the [upstream contributors](https://github.com/BigFatDog/parcoords-es/graphs/contributors)
155
163
 
156
164
  ## Contribution Notes
157
165
  Run `npm run pretty` before committing.
@@ -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.0";
3757
+ const version = "3.0.2";
3747
3758
 
3748
3759
  var DefaultConfig = {
3749
3760
  data: [],