@windborne/grapher 1.0.13 → 1.0.14

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.13",
3
+ "version": "1.0.14",
4
4
  "description": "Graphing library",
5
5
  "main": "bundle.js",
6
6
  "publishConfig": {},
package/readme.md CHANGED
@@ -97,7 +97,7 @@ The `series` prop requires an array of objects, where each object represents a d
97
97
  - **gradient**: Gradient configuration, only applies to area rendering (array)
98
98
  - **zeroLineWidth**: Width of the zero line, only applies to bar and area rendering (number)
99
99
  - **zeroLineColor**: Color of the zero line, only applies to bar and area rendering (string)
100
- - **zeroLineY**: Y-coordinate of the zero line, only applies to bar and area rendering (number). Defaults to zero.
100
+ - **zeroLineY**: Y-coordinate of the zero line, only applies to bar and area rendering (number or "bottom"). Defaults to zero; may also be the string "bottom".
101
101
  - **pointRadius**: Radius of points, only applies to area rendering (number)
102
102
  - **tooltipWidth**: Expected width of the tooltip (number). Will make the tooltip switch sides when this width plus the tooltip left position is greater than the graph width.
103
103
  - **hasAreaBottom**: read the bottom of the area from data (boolean). By default, the bottom of an area will just be zero; this allows changing that via passing in `[[x1, bottom], [x1, top], [x2, bottom], [x2, top]]` to data (see [examples/dynamic_bottom_area_chart.js](examples/dynamic_bottom_area_chart.js)).
@@ -70,7 +70,7 @@ const SingleSeries = PropTypes.shape({
70
70
  gradient: PropTypes.array, // only applies to area
71
71
  zeroLineWidth: PropTypes.number, // only applies to bar and area
72
72
  zeroLineColor: PropTypes.string, // only applies to bar and area
73
- zeroLineY: PropTypes.number, // only applies to bar and area
73
+ zeroLineY: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), // only applies to bar and area
74
74
  pointRadius: PropTypes.number, // only applies to area
75
75
  tooltipWidth: PropTypes.number,
76
76
  hasAreaBottom: PropTypes.bool,
@@ -156,11 +156,15 @@ export default class GraphBodyRenderer extends Eventable {
156
156
  bounds = singleSeries.axis.currentBounds;
157
157
  }
158
158
 
159
+ const zero = singleSeries.zeroLineY === 'bottom' ?
160
+ this._sizing.renderHeight :
161
+ (1.0 - ((singleSeries.zeroLineY || 0) - bounds.minY) / (bounds.maxY - bounds.minY)) * this._sizing.renderHeight;
162
+
159
163
  commonCPUParams = {
160
164
  context: this._context2d,
161
165
  color: getColor(singleSeries.color, singleSeries.index, singleSeries.multigrapherSeriesIndex),
162
166
  sizing: this._sizing,
163
- zero: (1.0 - ((singleSeries.zeroLineY || 0) - bounds.minY) / (bounds.maxY - bounds.minY)) * this._sizing.renderHeight,
167
+ zero,
164
168
  hasNegatives: !!singleSeries.inDataSpace.find((tuple) => tuple[1] < 0),
165
169
  negativeColor: singleSeries.negativeColor,
166
170
  zeroWidth: singleSeries.zeroLineWidth,