plottable 3.9.0-dev-86-g70f2b1ac → 3.9.0-dev-88-gcef9ab26

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.
@@ -10,4 +10,4 @@ exports.version = void 0;
10
10
  * real version number during the dist phase for for npm module publishing. Modifying this line should
11
11
  * be accompanied by modifying the "sed-version" task in package.json accordingly.
12
12
  */
13
- exports.version = "3.9.0-dev-86-g70f2b1ac";
13
+ exports.version = "3.9.0-dev-88-gcef9ab26";
@@ -24,6 +24,10 @@ export declare class SVGDrawer implements IDrawer {
24
24
  * All of the DOM elements from the last draw.
25
25
  */
26
26
  private _selection;
27
+ /**
28
+ * The source data index of each element in _selection, by position
29
+ */
30
+ private _sourceDataIndices;
27
31
  /**
28
32
  * Cache of the _selection.nodes().
29
33
  */
@@ -78,10 +78,12 @@ var SVGDrawer = /** @class */ (function () {
78
78
  // first store source data index before any filtering takes place
79
79
  var mappedData = data.map(function (d, i) { return d != null ? { d: d, i: i } : null; });
80
80
  // Whereas canvas renders can cope with null data values, svg renderer
81
- // attribute accessors assume non-null data values, so we must filter them
82
- // out. Unfortunately, this means the index passed to each accessor will
83
- // not necessarily match the index of the datum in the dataset.
81
+ // attribute accessors assume non-null data values, so we must filter them out
84
82
  var filteredData = mappedData.filter(function (d) { return d != null; });
83
+ this._sourceDataIndices = filteredData.map(function (_a) {
84
+ var i = _a.i;
85
+ return i;
86
+ });
85
87
  var dataElementsUpdate = this._root.selectAll(this.selector()).data(filteredData);
86
88
  this._selection = dataElementsUpdate
87
89
  .enter()
@@ -115,13 +117,20 @@ var SVGDrawer = /** @class */ (function () {
115
117
  */
116
118
  SVGDrawer.prototype._drawStep = function (step) {
117
119
  var _this = this;
120
+ // d3 passes each element's position in _selection, which skips null data, so map it back to the source data index
121
+ var sourceDataIndices = this._sourceDataIndices;
122
+ var attrToSourceIndexProjector = {};
123
+ Object.keys(step.attrToAppliedProjector).forEach(function (attr) {
124
+ var projector = step.attrToAppliedProjector[attr];
125
+ attrToSourceIndexProjector[attr] = function (datum, position) { return projector(datum, sourceDataIndices[position]); };
126
+ });
118
127
  var colorAttributes = ["fill", "stroke"];
119
128
  colorAttributes.forEach(function (colorAttribute) {
120
- if (step.attrToAppliedProjector[colorAttribute] != null) {
121
- _this._selection.attr(colorAttribute, step.attrToAppliedProjector[colorAttribute]);
129
+ if (attrToSourceIndexProjector[colorAttribute] != null) {
130
+ _this._selection.attr(colorAttribute, attrToSourceIndexProjector[colorAttribute]);
122
131
  }
123
132
  });
124
- step.animator.animate(this._selection, step.attrToAppliedProjector);
133
+ step.animator.animate(this._selection, attrToSourceIndexProjector);
125
134
  if (this._className != null) {
126
135
  this._selection.classed(this._className, true);
127
136
  }
@@ -33,8 +33,40 @@ var IndexMap = /** @class */ (function () {
33
33
  return IndexMap;
34
34
  }());
35
35
  /**
36
- * A lodash-style `MapCache` that utilizes a [number, number] key to create a
37
- * fast-lookup 2D index. This is much faster than stringifying the key.
36
+ * An `IndexMap` that records the datum each value was computed for in place of
37
+ * an existence flag, so a lookup only matches that datum
38
+ */
39
+ var DatumIndexMap = /** @class */ (function () {
40
+ function DatumIndexMap() {
41
+ this.values = Object.create(null);
42
+ this.datums = Object.create(null);
43
+ }
44
+ DatumIndexMap.prototype.delete = function (key) {
45
+ delete this.values[key];
46
+ delete this.datums[key];
47
+ return true;
48
+ };
49
+ DatumIndexMap.prototype.get = function (key) {
50
+ return this.values[key];
51
+ };
52
+ DatumIndexMap.prototype.has = function (key, datum) {
53
+ return this.datums[key] === datum && (datum !== undefined || key in this.datums);
54
+ };
55
+ DatumIndexMap.prototype.set = function (key, datum, value) {
56
+ this.values[key] = value;
57
+ this.datums[key] = datum;
58
+ return this;
59
+ };
60
+ return DatumIndexMap;
61
+ }());
62
+ /**
63
+ * A lodash-style `MapCache` keyed by [updateId, index, datum], stored as a
64
+ * fast-lookup 2D index on the first two. This is much faster than stringifying
65
+ * the key.
66
+ *
67
+ * Entries only match the datum they were computed for, because plots that
68
+ * filter data before drawing call projectors with each datum's position in the
69
+ * filtered data rather than its dataset index.
38
70
  */
39
71
  var DatasetIndexCache = /** @class */ (function () {
40
72
  function DatasetIndexCache() {
@@ -44,24 +76,24 @@ var DatasetIndexCache = /** @class */ (function () {
44
76
  return this.map.get(key[0]).get(key[1]);
45
77
  };
46
78
  DatasetIndexCache.prototype.has = function (key) {
47
- return this.map.has(key[0]) && this.map.get(key[0]).has(key[1]);
79
+ return this.map.has(key[0]) && this.map.get(key[0]).has(key[1], key[2]);
48
80
  };
49
81
  DatasetIndexCache.prototype.set = function (key, value) {
50
- this.map.has(key[0]) || this.map.set(key[0], new IndexMap());
51
- this.map.get(key[0]).set(key[1], value);
82
+ this.map.has(key[0]) || this.map.set(key[0], new DatumIndexMap());
83
+ this.map.get(key[0]).set(key[1], key[2], value);
52
84
  return this;
53
85
  };
54
86
  DatasetIndexCache.prototype.delete = function (key) {
55
- // NOTE: this can potentially leave dangling `IndexMap`s if we delete
56
- // all the keys from the index instead of using `clear`. The overhead is
57
- // minimal, so this is fine.
87
+ // NOTE: this can potentially leave dangling `DatumIndexMap`s if we
88
+ // delete all the keys from the index instead of using `clear`. The
89
+ // overhead is minimal, so this is fine.
58
90
  this.map.has(key[0]) && this.map.get(key[0]).delete(key[1]);
59
91
  return true;
60
92
  };
61
93
  DatasetIndexCache.prototype.clear = function () {
62
94
  this.map = new IndexMap();
63
95
  };
64
- DatasetIndexCache.resolver = function (d, i, dataset) { return [dataset.updateId(), i]; };
96
+ DatasetIndexCache.resolver = function (d, i, dataset) { return [dataset.updateId(), i, d]; };
65
97
  return DatasetIndexCache;
66
98
  }());
67
99
  function memoizeProjector(projector) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "plottable",
3
3
  "description": "A modular charting library built on D3",
4
- "version": "3.9.0-dev-86-g70f2b1ac",
4
+ "version": "3.9.0-dev-88-gcef9ab26",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
package/plottable.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Plottable 4.1.0 (https://github.com/palantir/plottable)
2
+ * Plottable 4.1.1 (https://github.com/palantir/plottable)
3
3
  * Copyright 2014-2017 Palantir Technologies
4
4
  * Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE)
5
5
  */
@@ -2288,10 +2288,12 @@ var SVGDrawer = /** @class */ (function () {
2288
2288
  // first store source data index before any filtering takes place
2289
2289
  var mappedData = data.map(function (d, i) { return d != null ? { d: d, i: i } : null; });
2290
2290
  // Whereas canvas renders can cope with null data values, svg renderer
2291
- // attribute accessors assume non-null data values, so we must filter them
2292
- // out. Unfortunately, this means the index passed to each accessor will
2293
- // not necessarily match the index of the datum in the dataset.
2291
+ // attribute accessors assume non-null data values, so we must filter them out
2294
2292
  var filteredData = mappedData.filter(function (d) { return d != null; });
2293
+ this._sourceDataIndices = filteredData.map(function (_a) {
2294
+ var i = _a.i;
2295
+ return i;
2296
+ });
2295
2297
  var dataElementsUpdate = this._root.selectAll(this.selector()).data(filteredData);
2296
2298
  this._selection = dataElementsUpdate
2297
2299
  .enter()
@@ -2325,13 +2327,20 @@ var SVGDrawer = /** @class */ (function () {
2325
2327
  */
2326
2328
  SVGDrawer.prototype._drawStep = function (step) {
2327
2329
  var _this = this;
2330
+ // d3 passes each element's position in _selection, which skips null data, so map it back to the source data index
2331
+ var sourceDataIndices = this._sourceDataIndices;
2332
+ var attrToSourceIndexProjector = {};
2333
+ Object.keys(step.attrToAppliedProjector).forEach(function (attr) {
2334
+ var projector = step.attrToAppliedProjector[attr];
2335
+ attrToSourceIndexProjector[attr] = function (datum, position) { return projector(datum, sourceDataIndices[position]); };
2336
+ });
2328
2337
  var colorAttributes = ["fill", "stroke"];
2329
2338
  colorAttributes.forEach(function (colorAttribute) {
2330
- if (step.attrToAppliedProjector[colorAttribute] != null) {
2331
- _this._selection.attr(colorAttribute, step.attrToAppliedProjector[colorAttribute]);
2339
+ if (attrToSourceIndexProjector[colorAttribute] != null) {
2340
+ _this._selection.attr(colorAttribute, attrToSourceIndexProjector[colorAttribute]);
2332
2341
  }
2333
2342
  });
2334
- step.animator.animate(this._selection, step.attrToAppliedProjector);
2343
+ step.animator.animate(this._selection, attrToSourceIndexProjector);
2335
2344
  if (this._className != null) {
2336
2345
  this._selection.classed(this._className, true);
2337
2346
  }
@@ -11472,7 +11481,7 @@ exports.version = void 0;
11472
11481
  * real version number during the dist phase for for npm module publishing. Modifying this line should
11473
11482
  * be accompanied by modifying the "sed-version" task in package.json accordingly.
11474
11483
  */
11475
- exports.version = "4.1.0";
11484
+ exports.version = "4.1.1";
11476
11485
 
11477
11486
 
11478
11487
  /***/ }),
@@ -15981,8 +15990,40 @@ var IndexMap = /** @class */ (function () {
15981
15990
  return IndexMap;
15982
15991
  }());
15983
15992
  /**
15984
- * A lodash-style `MapCache` that utilizes a [number, number] key to create a
15985
- * fast-lookup 2D index. This is much faster than stringifying the key.
15993
+ * An `IndexMap` that records the datum each value was computed for in place of
15994
+ * an existence flag, so a lookup only matches that datum
15995
+ */
15996
+ var DatumIndexMap = /** @class */ (function () {
15997
+ function DatumIndexMap() {
15998
+ this.values = Object.create(null);
15999
+ this.datums = Object.create(null);
16000
+ }
16001
+ DatumIndexMap.prototype.delete = function (key) {
16002
+ delete this.values[key];
16003
+ delete this.datums[key];
16004
+ return true;
16005
+ };
16006
+ DatumIndexMap.prototype.get = function (key) {
16007
+ return this.values[key];
16008
+ };
16009
+ DatumIndexMap.prototype.has = function (key, datum) {
16010
+ return this.datums[key] === datum && (datum !== undefined || key in this.datums);
16011
+ };
16012
+ DatumIndexMap.prototype.set = function (key, datum, value) {
16013
+ this.values[key] = value;
16014
+ this.datums[key] = datum;
16015
+ return this;
16016
+ };
16017
+ return DatumIndexMap;
16018
+ }());
16019
+ /**
16020
+ * A lodash-style `MapCache` keyed by [updateId, index, datum], stored as a
16021
+ * fast-lookup 2D index on the first two. This is much faster than stringifying
16022
+ * the key.
16023
+ *
16024
+ * Entries only match the datum they were computed for, because plots that
16025
+ * filter data before drawing call projectors with each datum's position in the
16026
+ * filtered data rather than its dataset index.
15986
16027
  */
15987
16028
  var DatasetIndexCache = /** @class */ (function () {
15988
16029
  function DatasetIndexCache() {
@@ -15992,24 +16033,24 @@ var DatasetIndexCache = /** @class */ (function () {
15992
16033
  return this.map.get(key[0]).get(key[1]);
15993
16034
  };
15994
16035
  DatasetIndexCache.prototype.has = function (key) {
15995
- return this.map.has(key[0]) && this.map.get(key[0]).has(key[1]);
16036
+ return this.map.has(key[0]) && this.map.get(key[0]).has(key[1], key[2]);
15996
16037
  };
15997
16038
  DatasetIndexCache.prototype.set = function (key, value) {
15998
- this.map.has(key[0]) || this.map.set(key[0], new IndexMap());
15999
- this.map.get(key[0]).set(key[1], value);
16039
+ this.map.has(key[0]) || this.map.set(key[0], new DatumIndexMap());
16040
+ this.map.get(key[0]).set(key[1], key[2], value);
16000
16041
  return this;
16001
16042
  };
16002
16043
  DatasetIndexCache.prototype.delete = function (key) {
16003
- // NOTE: this can potentially leave dangling `IndexMap`s if we delete
16004
- // all the keys from the index instead of using `clear`. The overhead is
16005
- // minimal, so this is fine.
16044
+ // NOTE: this can potentially leave dangling `DatumIndexMap`s if we
16045
+ // delete all the keys from the index instead of using `clear`. The
16046
+ // overhead is minimal, so this is fine.
16006
16047
  this.map.has(key[0]) && this.map.get(key[0]).delete(key[1]);
16007
16048
  return true;
16008
16049
  };
16009
16050
  DatasetIndexCache.prototype.clear = function () {
16010
16051
  this.map = new IndexMap();
16011
16052
  };
16012
- DatasetIndexCache.resolver = function (d, i, dataset) { return [dataset.updateId(), i]; };
16053
+ DatasetIndexCache.resolver = function (d, i, dataset) { return [dataset.updateId(), i, d]; };
16013
16054
  return DatasetIndexCache;
16014
16055
  }());
16015
16056
  function memoizeProjector(projector) {