Skip to content

Commit 08dfaeb

Browse files
committed
[shared] remove extra tooltip padding. [xy-chart] fix bar offset and findclosestdatum bugs
1 parent 488e821 commit 08dfaeb

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

packages/shared/src/enhancer/WithTooltip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class WithTooltip extends React.PureComponent {
5959
}
6060

6161
this.props.showTooltip({
62-
tooltipLeft: coords.x + 10,
63-
tooltipTop: coords.y + 10,
62+
tooltipLeft: coords.x,
63+
tooltipTop: coords.y,
6464
tooltipData: {
6565
event,
6666
datum,

packages/xy-chart/src/chart/XYChart.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class XYChart extends React.PureComponent {
9595

9696
React.Children.forEach(children, (Child) => { // Child-specific scales or adjustments here
9797
const name = componentName(Child);
98-
if (isBarSeries(name) && xScale.type !== 'band') {
98+
if (isBarSeries(name) && xScaleObject.type !== 'band') {
9999
const dummyBand = getScaleForAccessor({
100100
allData,
101101
minAccessor: xString,
@@ -104,7 +104,7 @@ class XYChart extends React.PureComponent {
104104
rangeRound: [0, innerWidth],
105105
paddingOuter: 1,
106106
});
107-
107+
108108
const offset = dummyBand.bandwidth() / 2;
109109
xScale.range([offset, innerWidth - offset]);
110110
xScale.barWidth = dummyBand.bandwidth();

packages/xy-chart/src/series/AreaSeries.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ const defaultProps = {
4545
onMouseLeave: null,
4646
};
4747

48-
const x = d => d.x;
49-
const getY = d => d.y;
50-
const getY0 = d => d.y0;
51-
const getY1 = d => d.y1;
48+
const x = d => d && d.x;
49+
const getY = d => d && d.y;
50+
const getY0 = d => d && d.y0;
51+
const getY1 = d => d && d.y1;
5252
const definedClosed = d => isDefined(getY(d));
5353
const definedOpen = d => isDefined(getY0(d)) && isDefined(getY1(d));
5454
const noEventsStyles = { pointerEvents: 'none' };

packages/xy-chart/src/series/StackedAreaSeries.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ const defaultProps = {
4242
onMouseLeave: null,
4343
};
4444

45-
const x = d => d.x;
46-
const y0 = d => d[0];
47-
const y1 = d => d[1];
45+
const x = d => d && d.x;
46+
const y0 = d => d && d[0];
47+
const y1 = d => d && d[1];
4848
const defined = d => isDefined(d[0]) && isDefined(d[1]);
4949
const noEventsStyles = { pointerEvents: 'none' };
5050

0 commit comments

Comments
 (0)