Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react-chart): fix spacing on axis labels in Edge #2006

Merged
merged 6 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/dx-chart-core/src/plugins/axis/computeds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('axisCoordinates', () => {
xText: 25,
yText: -10,
text: 1,
dominantBaseline: 'baseline',
dy: '0em',
textAnchor: 'middle',
y1: 0, y2: -5, x1: 25, x2: 25,
}],
Expand All @@ -53,7 +53,7 @@ describe('axisCoordinates', () => {
xText: 25,
yText: 10,
text: 1,
dominantBaseline: 'hanging',
dy: '1em',
textAnchor: 'middle',
y1: 0, y2: 5, x1: 25, x2: 25,
}],
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('axisCoordinates', () => {
xText: -10,
yText: 25,
x1: 0, x2: -5, y1: 25, y2: 25,
dominantBaseline: 'middle',
dy: '0.3em',
textAnchor: 'end',
}],
});
Expand All @@ -110,7 +110,7 @@ describe('axisCoordinates', () => {
xText: 10,
yText: 25,
x1: 0, x2: 5, y1: 25, y2: 25,
dominantBaseline: 'middle',
dy: '0.3em',
textAnchor: 'start',
}],
});
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('axisCoordinates', () => {
xText: 25,
yText: -10,
text: 'format 1',
dominantBaseline: 'baseline',
dy: '0em',
textAnchor: 'middle',
y1: 0, y2: -5, x1: 25, x2: 25,
}]);
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('axisCoordinates', () => {
xText: 25,
yText: -10,
text: 'user format 1',
dominantBaseline: 'baseline',
dy: '0em',
textAnchor: 'middle',
y1: 0, y2: -5, x1: 25, x2: 25,
}]);
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('axisCoordinates', () => {
xText: 25,
yText: 10,
text: 'a',
dominantBaseline: 'hanging',
dy: '1em',
textAnchor: 'middle',
y1: 0, y2: 5, x1: 25, x2: 25,
}],
Expand All @@ -232,7 +232,7 @@ describe('axisCoordinates', () => {
xText: 25,
yText: -10,
text: 'a',
dominantBaseline: 'baseline',
dy: '0em',
textAnchor: 'middle',
y1: 0, y2: -5, x1: 25, x2: 25,
}],
Expand All @@ -253,7 +253,7 @@ describe('axisCoordinates', () => {
xText: -10,
yText: 25,
x1: 0, x2: -5, y1: 25, y2: 25,
dominantBaseline: 'middle',
dy: '0.3em',
textAnchor: 'end',
}],
});
Expand All @@ -273,7 +273,7 @@ describe('axisCoordinates', () => {
xText: 10,
yText: 25,
x1: 0, x2: 5, y1: 25, y2: 25,
dominantBaseline: 'middle',
dy: '0.3em',
textAnchor: 'start',
}],
});
Expand Down
4 changes: 2 additions & 2 deletions packages/dx-chart-core/src/plugins/axis/computeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const createHorizontalOptions = (position: string, tickSize: number, indentFromA
y1: 0,
y2: isStart ? +tickSize : -tickSize,
yText: isStart ? +indentFromAxis : -indentFromAxis,
dominantBaseline: isStart ? 'hanging' : 'baseline',
dy: isStart ? '1em' : '0em',
textAnchor: MIDDLE,
};
};
Expand All @@ -45,7 +45,7 @@ const createVerticalOptions = (position: string, tickSize: number, indentFromAxi
x1: 0,
x2: isStart ? -tickSize : +tickSize,
xText: isStart ? -indentFromAxis : +indentFromAxis,
dominantBaseline: MIDDLE,
dy: '0.3em',
textAnchor: isStart ? END : START,
};
};
Expand Down
2 changes: 1 addition & 1 deletion packages/dx-chart-core/src/types/plugins.axis.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type Tick = {
readonly y2: number;
readonly xText: number;
readonly yText: number;
readonly dominantBaseline: string;
readonly dy: string;
readonly textAnchor: string;
readonly text: string;
};
Expand Down
3 changes: 2 additions & 1 deletion packages/dx-react-chart/api/dx-react-chart.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface ArgumentScaleProps extends ScaleProps {
namespace Axis {
// (undocumented)
interface LabelProps {
dominantBaseline: string;
dy: string;
text: string | number;
textAnchor: string;
x: number;
Expand Down Expand Up @@ -635,3 +635,4 @@ interface ZoomAndPanProps {


// (No @packageDocumentation comment for this package)

2 changes: 1 addition & 1 deletion packages/dx-react-chart/docs/reference/argument-axis.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Field | Type | Description
text | string | number | The label text.
x | number | The x coordinate of the label's top left corner.
y | number | The y coordinate of the label's top left corner.
dominantBaseline | 'hanging' | 'middle' | 'baseline' | The label's baseline.
dy | string | The label's offset from baseline in css units.
Krijovnick marked this conversation as resolved.
Show resolved Hide resolved
textAnchor | 'start' | 'middle' | 'end' | The label's text alignment.

## Plugin Components
Expand Down
2 changes: 1 addition & 1 deletion packages/dx-react-chart/docs/reference/value-axis.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Field | Type | Description
text | string | number | The label text.
x | number | The x coordinate of the label's top left corner.
y | number | The y coordinate of the label's top left corner.
dominantBaseline | 'hanging' | 'middle' | 'baseline' | The label's baseline.
dy | string | The label's offset from baseline in css units.
Krijovnick marked this conversation as resolved.
Show resolved Hide resolved
textAnchor | 'start' | 'middle' | 'end' | The label's text alignment.

## Plugin Components
Expand Down
8 changes: 4 additions & 4 deletions packages/dx-react-chart/src/plugins/axis.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Axis', () => {
y2: 4,
xText: 'xText1',
yText: 'yText1',
dominantBaseline: 'dominantBaseline1',
dy: 'dy1',
textAnchor: 'textAnchor1',
key: '1',
},
Expand All @@ -90,7 +90,7 @@ describe('Axis', () => {
y2: 44,
xText: 'xText2',
yText: 'yText2',
dominantBaseline: 'dominantBaseline2',
dy: 'dy2',
textAnchor: 'textAnchor2',
key: '2',
},
Expand Down Expand Up @@ -332,15 +332,15 @@ describe('Axis', () => {
expect(tree.find(LabelComponent).get(0).props).toEqual({
x: 'xText1',
y: 'yText1',
dominantBaseline: 'dominantBaseline1',
dy: 'dy1',
textAnchor: 'textAnchor1',
text: 'text1',
});

expect(tree.find(LabelComponent).get(1).props).toEqual({
x: 'xText2',
y: 'yText2',
dominantBaseline: 'dominantBaseline2',
dy: 'dy2',
textAnchor: 'textAnchor2',
text: 'text2',
});
Expand Down
4 changes: 2 additions & 2 deletions packages/dx-react-chart/src/plugins/axis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class RawAxis extends React.PureComponent<RawAxisProps> {
text,
xText,
yText,
dominantBaseline,
dy: delta,
textAnchor,
key,
}) => (
Expand All @@ -156,7 +156,7 @@ class RawAxis extends React.PureComponent<RawAxisProps> {
text={text}
x={xText}
y={yText}
dominantBaseline={dominantBaseline}
dy={delta}
textAnchor={textAnchor}
/>
))}
Expand Down
6 changes: 3 additions & 3 deletions packages/dx-react-chart/src/templates/axis/label.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const defaultProps = {
x: 1,
y: 2,
text: 'a',
dominantBaseline: 'middle',
dy: '1em',
textAnchor: 'end',
};

Expand All @@ -15,11 +15,11 @@ describe('Label', () => {
const tree = shallow(<Label {...defaultProps} />);

const {
x, y, dominantBaseline, textAnchor,
x, y, dy, textAnchor,
} = tree.find('text').props();
expect(x).toBe(1);
expect(y).toBe(2);
expect(dominantBaseline).toBe('middle');
expect(dy).toBe('1em');
expect(textAnchor).toBe('end');
expect(tree.text()).toBe('a');
});
Expand Down
6 changes: 1 addition & 5 deletions packages/dx-react-chart/src/templates/axis/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ import { Axis } from '../../types';
export class Label extends React.PureComponent<Axis.LabelProps> {
render() {
const {
text, x, y, dominantBaseline, textAnchor, ...restProps
text, ...restProps
} = this.props;

return (
Krijovnick marked this conversation as resolved.
Show resolved Hide resolved
<text
dominantBaseline={dominantBaseline}
textAnchor={textAnchor}
x={x}
y={y}
{...restProps}
>
{text}
Expand Down
4 changes: 2 additions & 2 deletions packages/dx-react-chart/src/types/templates.axis.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export namespace Axis {
x: number;
/** The y coordinate of the label’s top left corner */
y: number;
/** The label’s baseline */
dominantBaseline: string;
/** The label's offset from baseline in css units */
Krijovnick marked this conversation as resolved.
Show resolved Hide resolved
dy: string;
/** The label’s text alignment */
textAnchor: string;
}
Expand Down