@windborne/grapher 1.0.47 → 1.0.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windborne/grapher",
3
- "version": "1.0.47",
3
+ "version": "1.0.48",
4
4
  "description": "Graphing library",
5
5
  "main": "src/index.js",
6
6
  "module": "dist/bundle.esm.js",
@@ -2,7 +2,7 @@ function finalizeBounds(bounds, { dates }) {
2
2
  const initial = (bounds.minX === null && bounds.maxX === null) || bounds.minY === null || bounds.maxY === null;
3
3
 
4
4
  for (let key of Object.keys(bounds)) {
5
- if (typeof bounds[key] !== 'number') {
5
+ if (typeof bounds[key] !== 'number' && bounds[key] !== null) {
6
6
  bounds[key] = 0;
7
7
  }
8
8
  }
@@ -19,23 +19,23 @@ export default function mergeBounds(boundsList) {
19
19
  }
20
20
  mergedBounds.initial = false;
21
21
 
22
- if (mergedBounds.minX === null || minX < mergedBounds.minX) {
22
+ if (minX !== null && (mergedBounds.minX === null || minX < mergedBounds.minX)) {
23
23
  mergedBounds.minX = minX;
24
24
  }
25
25
 
26
- if (mergedBounds.maxX === null || maxX > mergedBounds.maxX) {
26
+ if (maxX !== null && (mergedBounds.maxX === null || maxX > mergedBounds.maxX)) {
27
27
  mergedBounds.maxX = maxX;
28
28
  }
29
29
 
30
- if (mergedBounds.closestSpacing === null || closestSpacing < mergedBounds.closestSpacing) {
30
+ if (closestSpacing !== null && (mergedBounds.closestSpacing === null || closestSpacing < mergedBounds.closestSpacing)) {
31
31
  mergedBounds.closestSpacing = closestSpacing;
32
32
  }
33
33
 
34
- if (mergedBounds.minY === null || minY < mergedBounds.minY) {
34
+ if (minY !== null && (mergedBounds.minY === null || minY < mergedBounds.minY)) {
35
35
  mergedBounds.minY = minY;
36
36
  }
37
37
 
38
- if (mergedBounds.maxY === null || maxY > mergedBounds.maxY) {
38
+ if (maxY !== null && (mergedBounds.maxY === null || maxY > mergedBounds.maxY)) {
39
39
  mergedBounds.maxY = maxY;
40
40
  }
41
41
  }
@@ -802,15 +802,27 @@ export default class StateController extends Eventable {
802
802
  const expandYWith = [];
803
803
  for (let singleSeries of axis.series) {
804
804
  if (singleSeries._rangeValues && singleSeries._rangeValues.length > 0) {
805
- const visibleDataPoints = singleSeries.inDataSpace.filter(([x, y]) =>
806
- axis.targetBounds.minX <= x && x <= axis.targetBounds.maxX
807
- );
808
-
809
805
  const visibleRangeValues = [];
810
- for (let i = 0; i < visibleDataPoints.length; i++) {
811
- const dataPointIndex = singleSeries.inDataSpace.indexOf(visibleDataPoints[i]);
812
- if (dataPointIndex >= 0) {
813
- const rangeIndex = dataPointIndex * 2;
806
+
807
+ for (let i = 0; i < singleSeries.inDataSpace.length; i++) {
808
+ const [x, y] = singleSeries.inDataSpace[i];
809
+ let xValue = x;
810
+ let minXValue = axis.targetBounds.minX;
811
+ let maxXValue = axis.targetBounds.maxX;
812
+
813
+ if (x instanceof Date) {
814
+ xValue = x.valueOf();
815
+ }
816
+ if (minXValue instanceof Date) {
817
+ minXValue = minXValue.valueOf();
818
+ }
819
+ if (maxXValue instanceof Date) {
820
+ maxXValue = maxXValue.valueOf();
821
+ }
822
+
823
+ if (minXValue !== null && maxXValue !== null &&
824
+ xValue >= minXValue && xValue <= maxXValue) {
825
+ const rangeIndex = i * 2;
814
826
  if (rangeIndex < singleSeries._rangeValues.length) {
815
827
  visibleRangeValues.push(singleSeries._rangeValues[rangeIndex]);
816
828
  if (rangeIndex + 1 < singleSeries._rangeValues.length) {
@@ -854,15 +866,27 @@ export default class StateController extends Eventable {
854
866
  }
855
867
 
856
868
  if (singleSeries._rangeValues && singleSeries._rangeValues.length > 0) {
857
- const visibleDataPoints = singleSeries.inDataSpace.filter(([x, y]) =>
858
- singleSeries.selectedBounds.minX <= x && x <= singleSeries.selectedBounds.maxX
859
- );
860
-
861
869
  const visibleRangeValues = [];
862
- for (let i = 0; i < visibleDataPoints.length; i++) {
863
- const dataPointIndex = singleSeries.inDataSpace.indexOf(visibleDataPoints[i]);
864
- if (dataPointIndex >= 0) {
865
- const rangeIndex = dataPointIndex * 2;
870
+
871
+ for (let i = 0; i < singleSeries.inDataSpace.length; i++) {
872
+ const [x, y] = singleSeries.inDataSpace[i];
873
+ let xValue = x;
874
+ let minXValue = singleSeries.selectedBounds.minX;
875
+ let maxXValue = singleSeries.selectedBounds.maxX;
876
+
877
+ if (x instanceof Date) {
878
+ xValue = x.valueOf();
879
+ }
880
+ if (minXValue instanceof Date) {
881
+ minXValue = minXValue.valueOf();
882
+ }
883
+ if (maxXValue instanceof Date) {
884
+ maxXValue = maxXValue.valueOf();
885
+ }
886
+
887
+ if (minXValue !== null && maxXValue !== null &&
888
+ xValue >= minXValue && xValue <= maxXValue) {
889
+ const rangeIndex = i * 2;
866
890
  if (rangeIndex < singleSeries._rangeValues.length) {
867
891
  visibleRangeValues.push(singleSeries._rangeValues[rangeIndex]);
868
892
  if (rangeIndex + 1 < singleSeries._rangeValues.length) {