@windborne/grapher 1.0.5 → 1.0.6

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.5",
3
+ "version": "1.0.6",
4
4
  "description": "Graphing library",
5
5
  "main": "bundle.js",
6
6
  "publishConfig": {},
package/readme.md CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- # Grapher
2
+ # WindBorne Grapher
3
3
  Powerful, performant graphing.
4
4
 
5
5
  Grapher is designed primarily for internal infrastructure with lots of data and lots of axes.
@@ -300,6 +300,8 @@ Array of vertical line objects to display on the graph with properties:
300
300
  - `text`: Optional text to display alongside the line
301
301
  - `textTop`: Optional value to specify the vertical position of the text
302
302
  - `textStyle`: Optional styling object for the text
303
+ - `minPixelX`: Optional number. If the x position of the line in pixels is less than this value, the line will be hidden
304
+ - `maxPixelX`: Optional number. If the x position of the line in pixels is greater than this value, the line will be hidden
303
305
  - `onRangeGraph`: If true, will show the line on the range graph as well. This may also be an object with any of the above options to adjust the styling
304
306
  - `onRangeGraphOnly`: If true, the vertical line will only appear on the range graph and not the primary graph
305
307
 
@@ -42,7 +42,6 @@ function VerticalLines({ stateController, verticalLines, isRangeGraph, bounds, e
42
42
  };
43
43
  }
44
44
 
45
-
46
45
  const xT = (line.x - bounds.minX)/(bounds.maxX - bounds.minX);
47
46
 
48
47
  if (xT < 0 || xT > 1) {
@@ -50,6 +49,13 @@ function VerticalLines({ stateController, verticalLines, isRangeGraph, bounds, e
50
49
  }
51
50
 
52
51
  const pixelX = xT * (elementWidth || sizing.elementWidth);
52
+ if (typeof line.minPixelX === 'number' && pixelX < line.minPixelX) {
53
+ return null;
54
+ }
55
+
56
+ if (typeof line.maxPixelX === 'number' && pixelX > line.maxPixelX) {
57
+ return null;
58
+ }
53
59
 
54
60
  const lineStyle = {
55
61
  stroke: line.color,
@@ -142,6 +142,8 @@ const VerticalLine = PropTypes.shape({
142
142
  text: PropTypes.string,
143
143
  textTop: PropTypes.number,
144
144
  textStyle: PropTypes.object,
145
+ minPixelX: PropTypes.number,
146
+ maxPixelX: PropTypes.number,
145
147
  onRangeGraph: PropTypes.oneOfType([
146
148
  PropTypes.bool,
147
149
  PropTypes.object // anything that can be passed into the overall vertical line