Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

[ENH] Add sortOrder prop #160

Merged
merged 2 commits into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions src/components/victory-pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class VictoryPie extends React.Component {
PropTypes.string,
PropTypes.arrayOf(PropTypes.string)
]),
sortOder: PropTypes.oneOf(["ascending", "descending"]),
standalone: PropTypes.bool,
startAngle: PropTypes.number,
style: PropTypes.shape({
Expand Down Expand Up @@ -138,6 +139,7 @@ class VictoryPie extends React.Component {
labelComponent: <VictoryLabel/>,
containerComponent: <VictoryContainer/>,
groupComponent: <g/>,
sortOrder: "ascending",
theme: VictoryTheme.grayscale
};

Expand Down
14 changes: 14 additions & 0 deletions test/client/spec/components/victory-pie.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ describe("components/victory-pie", () => {

expect(xValues).to.eql([0, 1, 2, 3, 4, 5, 6, 7, 8]);
});

it("renders data values sorted by sortKey prop and sortOrder", () => {
const data = range(9).map((i) => ({ x: i, y: i }));

const wrapper = shallow(
<VictoryPie data={data} sortKey={"x"} sortOrder={"descending"}/>
);
const xValues = wrapper.find(Slice).map((slice) => {
return slice.prop("datum")._x;
});

expect(xValues).to.eql([8, 7, 6, 5, 4, 3, 2, 1, 0]);
});

});

describe("the `startAngle` prop", () => {
Expand Down