@windborne/grapher 1.0.55 → 1.0.56

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.55",
3
+ "version": "1.0.56",
4
4
  "description": "Graphing library",
5
5
  "main": "src/index.js",
6
6
  "module": "dist/bundle.esm.js",
@@ -33,7 +33,7 @@ export default function drawBars(individualPoints, {
33
33
  context.fillStyle = color;
34
34
 
35
35
  const {barWidth, totalBarWidth} = getBarWidths({ closestSpacing, bounds, sizing, axisSeriesCount });
36
- const barBottom = hasNegatives ? zero : sizing.renderHeight;
36
+ const barBottom = Math.min(zero, sizing.renderHeight);
37
37
 
38
38
  if (renderCutoffGradient && cutoffIndex !== undefined && originalData) {
39
39
  drawBarsWithCutoff(individualPoints, {
@@ -353,18 +353,15 @@ export default class GraphBodyRenderer extends Eventable {
353
353
 
354
354
  if (singleSeries.rendering === 'bar') {
355
355
  const barSeriesInAxis = singleSeries.axis.series.filter(s => s.rendering === 'bar');
356
- let barClosestSpacing = null;
357
- for (const s of barSeriesInAxis) {
358
- const sp = s.dataBounds?.closestSpacing;
359
- if (sp != null && sp > 0 && (barClosestSpacing === null || sp > barClosestSpacing)) {
360
- barClosestSpacing = sp;
361
- }
362
- }
356
+ const visibleBarSeries = barSeriesInAxis.filter(s =>
357
+ s.inDataSpace && s.inDataSpace.length > 0 &&
358
+ s.dataBounds && s.dataBounds.maxX >= bounds.minX && s.dataBounds.minX <= bounds.maxX
359
+ );
363
360
  let barParams = {
364
361
  ...commonCPUParams,
365
- indexInAxis: barSeriesInAxis.indexOf(singleSeries),
366
- axisSeriesCount: barSeriesInAxis.length,
367
- closestSpacing: barClosestSpacing || globalBounds.closestSpacing,
362
+ indexInAxis: visibleBarSeries.indexOf(singleSeries),
363
+ axisSeriesCount: visibleBarSeries.length || 1,
364
+ closestSpacing: singleSeries.dataBounds?.closestSpacing || globalBounds.closestSpacing,
368
365
  bounds
369
366
  };
370
367
 
@@ -110,19 +110,15 @@ export default function calculateTooltipState({mousePresent, mouseX, mouseY, siz
110
110
 
111
111
  if (singleSeries.rendering === 'bar') {
112
112
  const barSeriesInAxis = singleSeries.axis.series.filter(s => s.rendering === 'bar');
113
- const indexInAxis = barSeriesInAxis.indexOf(singleSeries);
114
- const axisSeriesCount = barSeriesInAxis.length;
115
-
116
- let barClosestSpacing = null;
117
- for (const s of barSeriesInAxis) {
118
- const sp = s.dataBounds?.closestSpacing;
119
- if (sp != null && sp > 0 && (barClosestSpacing === null || sp > barClosestSpacing)) {
120
- barClosestSpacing = sp;
121
- }
122
- }
113
+ const visibleBarSeries = barSeriesInAxis.filter(s =>
114
+ s.inDataSpace && s.inDataSpace.length > 0 &&
115
+ s.dataBounds && s.dataBounds.maxX >= bounds.minX && s.dataBounds.minX <= bounds.maxX
116
+ );
117
+ const indexInAxis = visibleBarSeries.indexOf(singleSeries);
118
+ const axisSeriesCount = visibleBarSeries.length || 1;
123
119
 
124
120
  const { totalBarWidth, barWidth } = getBarWidths({
125
- closestSpacing: barClosestSpacing || closestSpacing,
121
+ closestSpacing: singleSeries.dataBounds?.closestSpacing || closestSpacing,
126
122
  bounds,
127
123
  sizing,
128
124
  axisSeriesCount