Skip to content

Commit

Permalink
fix(coordinates): edge coordinates now go right up to the axis
Browse files Browse the repository at this point in the history
There was previously a small gap between the axis and the edge coordinate.
  • Loading branch information
markmcdowell committed Oct 8, 2019
1 parent 0223b6b commit ba44493
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/charts/src/coordinates/EdgeCoordinateV3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export function drawOnCanvas(ctx: CanvasRenderingContext2D, props) {
} else if (rectRadius) {
roundRect(ctx, x, y, rectWidth, rectHeight, 3);
} else {
ctx.rect(x + 0.5, y + 0.5, rectWidth, rectHeight);
ctx.rect(x - 0.5, y - 0.5, rectWidth, rectHeight);
}

ctx.fill();
Expand Down
25 changes: 16 additions & 9 deletions packages/charts/src/coordinates/MouseCoordinateY.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ export class MouseCoordinateY extends React.Component<MouseCoordinateYProps> {

private readonly renderSVG = (moreProps) => {
const props = this.helper(this.props, moreProps);
if (isNotDefined(props)) { return null; }
if (isNotDefined(props)) {
return null;
}

return renderSVG(props);
}

private readonly drawOnCanvas = (ctx: CanvasRenderingContext2D, moreProps) => {
const props = this.helper(this.props, moreProps);
if (isNotDefined(props)) { return null; }
if (isNotDefined(props)) {
return null;
}

drawOnCanvas(ctx, props);
}
Expand All @@ -72,11 +76,17 @@ export class MouseCoordinateY extends React.Component<MouseCoordinateYProps> {
const { chartId } = moreProps;
const { currentCharts, mouseXY } = moreProps;

if (isNotDefined(mouseXY)) { return null; }
if (currentCharts.indexOf(chartId) < 0) { return null; }
if (isNotDefined(mouseXY)) {
return null;
}
if (currentCharts.indexOf(chartId) < 0) {
return null;
}

const { show } = moreProps;
if (!show) { return null; }
if (!show) {
return null;
}

const y = mouseXY[1];
const { chartConfig: { yScale } } = moreProps;
Expand Down Expand Up @@ -113,24 +123,21 @@ export function getYCoordinate(y, displayValue, props, moreProps) {
hideLine,
fill,
opacity,

fontFamily,
fontSize,
textFill,

stroke,
strokeOpacity,
strokeWidth,

rectWidth,
rectHeight,

arrowWidth,
dx,
x1,
x2,
y1: y,
y2: y,
};

return coordinateProps;
}

0 comments on commit ba44493

Please sign in to comment.