Skip to content

Commit 5e3723c

Browse files
authored
Merge pull request #1780 from FormidableLabs/bug/remove-unused-axis-line-type-prop
remove unused type prop from axis primitives
2 parents 6c0fff3 + 9c93c10 commit 5e3723c

File tree

4 files changed

+41
-18
lines changed

4 files changed

+41
-18
lines changed

packages/victory-axis/src/helper-methods.js

-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ const getTickLabelProps = (layout, style, anchors, datum, text) => {
9292
const getGridProps = (layout, style, datum) => {
9393
const { edge, transform } = layout;
9494
return {
95-
type: "grid",
9695
x1: transform.x,
9796
y1: transform.y,
9897
x2: edge.x + transform.x,
@@ -106,7 +105,6 @@ const getAxisProps = (modifiedProps, calculatedValues, globalTransform) => {
106105
const { style, padding, isVertical } = calculatedValues;
107106
const { width, height } = modifiedProps;
108107
return {
109-
type: "axis",
110108
style: style.axis,
111109
x1: isVertical ? globalTransform.x : padding.left + globalTransform.x,
112110
x2: isVertical ? globalTransform.x : width - padding.right + globalTransform.x,

packages/victory-axis/src/victory-axis.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ class VictoryAxis extends React.Component {
112112
};
113113

114114
static defaultProps = {
115-
axisComponent: <LineSegment type={"axis"} />,
115+
axisComponent: <LineSegment />,
116116
axisLabelComponent: <VictoryLabel />,
117117
tickLabelComponent: <VictoryLabel />,
118-
tickComponent: <LineSegment type={"tick"} />,
119-
gridComponent: <LineSegment type={"grid"} />,
118+
tickComponent: <LineSegment />,
119+
gridComponent: <LineSegment />,
120120
standalone: true,
121121
theme: VictoryTheme.grayscale,
122122
containerComponent: <VictoryContainer />,

packages/victory-polar-axis/src/victory-polar-axis.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ class VictoryPolarAxis extends React.Component {
109109
};
110110

111111
static defaultProps = {
112-
axisComponent: <LineSegment type={"axis"} />,
112+
axisComponent: <LineSegment />,
113113
axisLabelComponent: <VictoryLabel />,
114-
circularAxisComponent: <Arc type={"axis"} />,
115-
circularGridComponent: <Arc type={"grid"} />,
114+
circularAxisComponent: <Arc />,
115+
circularGridComponent: <Arc />,
116116
containerComponent: <VictoryContainer />,
117117
endAngle: 360,
118-
gridComponent: <LineSegment type={"grid"} />,
118+
gridComponent: <LineSegment />,
119119
groupComponent: <g role="presentation" />,
120120
labelPlacement: "parallel",
121121
startAngle: 0,
122122
standalone: true,
123123
theme: VictoryTheme.grayscale,
124-
tickComponent: <LineSegment type={"tick"} />,
124+
tickComponent: <LineSegment />,
125125
tickLabelComponent: <VictoryLabel />
126126
};
127127

test/client/spec/victory-axis/victory-axis.spec.js

+33-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { omit } from "lodash";
1010
import { shallow, mount } from "enzyme";
1111
import SvgTestHelper from "../svg-test-helper";
1212
import { VictoryAxis } from "packages/victory-axis/src/index";
13-
import { VictoryLabel } from "packages/victory-core/src/index";
13+
import { VictoryLabel, LineSegment } from "packages/victory-core/src/index";
1414
import { TextSize } from "packages/victory-core";
1515

1616
describe("components/victory-axis", () => {
@@ -32,15 +32,27 @@ describe("components/victory-axis", () => {
3232
it("renders the appropriate number of ticks", () => {
3333
const tickValues = [1, 2, 3];
3434
const style = { ticks: { stroke: "black" } };
35-
const wrapper = shallow(<VictoryAxis tickValues={tickValues} style={style} />);
35+
const wrapper = shallow(
36+
<VictoryAxis
37+
tickValues={tickValues}
38+
style={style}
39+
tickComponent={<LineSegment type="tick" />}
40+
/>
41+
);
3642
const ticks = wrapper.find('[type="tick"]');
3743
expect(ticks.length).to.equal(tickValues.length);
3844
});
3945

4046
it("does not render invisible ticks", () => {
4147
const tickValues = [1, 2, 3];
4248
const style = { ticks: { stroke: "none" } };
43-
const wrapper = shallow(<VictoryAxis tickValues={tickValues} style={style} />);
49+
const wrapper = shallow(
50+
<VictoryAxis
51+
tickValues={tickValues}
52+
style={style}
53+
tickComponent={<LineSegment type="tick" />}
54+
/>
55+
);
4456
const ticks = wrapper.find('[type="tick"]');
4557
expect(ticks.length).to.equal(0);
4658
});
@@ -60,20 +72,21 @@ describe("components/victory-axis", () => {
6072
]}
6173
tickValues={tickValues}
6274
style={style}
75+
tickComponent={<LineSegment type="tick" />}
6376
/>
6477
);
6578
const ticks = wrapper.find('[type="tick"]');
6679
expect(ticks.length).to.equal(tickValues.length);
6780
});
6881

6982
it("renders ticks as lines", () => {
70-
const wrapper = mount(<VictoryAxis />);
83+
const wrapper = mount(<VictoryAxis axisComponent={<LineSegment type="axis" />} />);
7184
const ticks = wrapper.find('[type="axis"]');
7285
ticks.forEach(SvgTestHelper.expectIsALine);
7386
});
7487

7588
it("renders a line", () => {
76-
const wrapper = mount(<VictoryAxis />);
89+
const wrapper = mount(<VictoryAxis axisComponent={<LineSegment type="axis" />} />);
7790
const line = wrapper.find('[type="axis"]');
7891
SvgTestHelper.expectIsALine(line);
7992
});
@@ -112,14 +125,16 @@ describe("components/victory-axis", () => {
112125
describe("dependentAxis prop", () => {
113126
it("renders a horizontal axis by default", () => {
114127
const props = { padding: 50, width: 300 };
115-
const wrapper = mount(<VictoryAxis {...props} />);
128+
const wrapper = mount(<VictoryAxis {...props} axisComponent={<LineSegment type="axis" />} />);
116129
const line = wrapper.find('[type="axis"]');
117130
expect(SvgTestHelper.isHorizontalAxis(line, props)).to.equal(true);
118131
});
119132

120133
it("renders a vertical axis if specified", () => {
121134
const props = { padding: 50, height: 300 };
122-
const wrapper = mount(<VictoryAxis dependentAxis {...props} />);
135+
const wrapper = mount(
136+
<VictoryAxis dependentAxis {...props} axisComponent={<LineSegment type="axis" />} />
137+
);
123138
const line = wrapper.find('[type="axis"]');
124139
expect(SvgTestHelper.isVerticalAxis(line, props)).to.equal(true);
125140
});
@@ -155,6 +170,7 @@ describe("components/victory-axis", () => {
155170
eventHandlers: { onClick: clickHandler }
156171
}
157172
]}
173+
axisComponent={<LineSegment type="axis" />}
158174
/>
159175
);
160176
const Data = wrapper.find('[type="axis"]');
@@ -189,6 +205,7 @@ describe("components/victory-axis", () => {
189205
ticks: { stroke: "black" },
190206
tickLabels: { padding: 0 }
191207
}}
208+
tickComponent={<LineSegment type="tick" />}
192209
/>
193210
);
194211
expect(wrapper.find('[type="tick"]').length).to.equal(3);
@@ -206,7 +223,12 @@ describe("components/victory-axis", () => {
206223
it("renders the appropriate number of ticks with default options", () => {
207224
const style = { ticks: { stroke: "black" } };
208225
const wrapper = shallow(
209-
<VictoryAxis tickValues={["1", "2", "3"]} style={style} width={10} />
226+
<VictoryAxis
227+
tickValues={["1", "2", "3"]}
228+
style={style}
229+
width={10}
230+
tickComponent={<LineSegment type="tick" />}
231+
/>
210232
);
211233
expect(wrapper.find('[type="tick"]').length).to.equal(3);
212234
});
@@ -220,6 +242,7 @@ describe("components/victory-axis", () => {
220242
ticks: { stroke: "black" },
221243
tickLabels: { padding: 0 }
222244
}}
245+
tickComponent={<LineSegment type="tick" />}
223246
/>
224247
);
225248
expect(wrapper.find('[type="tick"]').length).to.equal(2);
@@ -272,6 +295,7 @@ describe("components/victory-axis", () => {
272295
ticks: { stroke: "black" },
273296
tickLabels: { padding: 10 }
274297
}}
298+
tickComponent={<LineSegment type="tick" />}
275299
/>
276300
);
277301
expect(wrapper.find('[type="tick"]').length).to.equal(2);
@@ -287,6 +311,7 @@ describe("components/victory-axis", () => {
287311
ticks: { stroke: "black" },
288312
tickLabels: { padding: { top: 10 } }
289313
}}
314+
tickComponent={<LineSegment type="tick" />}
290315
/>
291316
);
292317
expect(wrapper.find('[type="tick"]').length).to.equal(2);

0 commit comments

Comments
 (0)