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

primitives for VictoryBoxPlot #334

Merged
merged 10 commits into from
Mar 27, 2018
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"d3-scale": "^1.0.0",
"d3-shape": "^1.2.0",
"d3-timer": "^1.0.0",
"lodash": "^4.17.4"
"lodash": "^4.17.5"
},
"devDependencies": {
"builder-victory-component-dev": "^5.1.2",
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export { default as Point } from "./victory-primitives/point";
export { default as Slice } from "./victory-primitives/slice";
export { default as Voronoi } from "./victory-primitives/voronoi";
export { default as Flyout } from "./victory-primitives/flyout";
export { default as Whisker } from "./victory-primitives/whisker";
export { default as addEvents } from "./victory-util/add-events";
export { default as Collection } from "./victory-util/collection";
export { default as Data } from "./victory-util/data";
Expand Down
42 changes: 42 additions & 0 deletions src/victory-primitives/whisker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from "react";
import PropTypes from "prop-types";
import CommonProps from "./common-props";
import Line from "./line";
import { assign } from "lodash";

export default class Whisker extends React.Component {

static propTypes = {
...CommonProps,
groupComponent: PropTypes.element,
lineComponent: PropTypes.element,
majorWhisker: PropTypes.shape({
x1: PropTypes.number,
x2: PropTypes.number,
y1: PropTypes.number,
y2: PropTypes.number
}),
minorWhisker: PropTypes.shape({
x1: PropTypes.number,
x2: PropTypes.number,
y1: PropTypes.number,
y2: PropTypes.number
})
}

static defaultProps = {
groupComponent: <g />,
lineComponent: <Line/>
}

render() {
const {
groupComponent, lineComponent, style, events, className, majorWhisker, minorWhisker
} = this.props;
const baseProps = { style, events, className };
return React.cloneElement(groupComponent, {}, [
React.cloneElement(lineComponent, assign({ key: "major-whisker" }, baseProps, majorWhisker)),
React.cloneElement(lineComponent, assign({ key: "minor-whisker" }, baseProps, minorWhisker))
]);
}
}
44 changes: 30 additions & 14 deletions src/victory-theme/grayscale.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const colors = [
];

const charcoal = "#252525";
const grey = "#969696";
// *
// * Typography
// *
Expand Down Expand Up @@ -92,6 +93,21 @@ export default {
labels: baseLabelStyles
}
}, baseProps),
boxplot: assign({
style: {
max: { padding: 8, stroke: charcoal, strokeWidth: 1 },
maxLabel: baseLabelStyles,
median: { padding: 8, stroke: charcoal, strokeWidth: 1 },
medianLabel: baseLabelStyles,
min: { padding: 8, stroke: charcoal, strokeWidth: 1 },
minLabel: baseLabelStyles,
q1: { padding: 8, fill: grey },
q1Label: baseLabelStyles,
q3: { padding: 8, fill: grey },
q3Label: baseLabelStyles
},
boxWidth: 20
}, baseProps),
candlestick: assign({
style: {
data: {
Expand Down Expand Up @@ -120,6 +136,19 @@ export default {
group: assign({
colorScale: colors
}, baseProps),
legend: {
colorScale: colors,
gutter: 10,
orientation: "vertical",
titleOrientation: "top",
style: {
data: {
type: "circle"
},
labels: baseLabelStyles,
title: assign({}, baseLabelStyles, { padding: 5 })
}
},
line: assign({
style: {
data: {
Expand Down Expand Up @@ -183,18 +212,5 @@ export default {
pointerEvents: "none"
}
}
}, baseProps),
legend: {
colorScale: colors,
gutter: 10,
orientation: "vertical",
titleOrientation: "top",
style: {
data: {
type: "circle"
},
labels: baseLabelStyles,
title: assign({}, baseLabelStyles, { padding: 5 })
}
}
}, baseProps)
};
42 changes: 28 additions & 14 deletions src/victory-theme/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ export default {
labels: baseLabelStyles
}
}, baseProps),
boxplot: assign({
style: {
max: { padding, stroke: blueGrey700, strokeWidth: 1 },
maxLabel: baseLabelStyles,
median: { padding, stroke: blueGrey700, strokeWidth: 1 },
medianLabel: baseLabelStyles,
min: { padding, stroke: blueGrey700, strokeWidth: 1 },
minLabel: baseLabelStyles,
q1: { padding, fill: blueGrey700 },
q1Label: baseLabelStyles,
q3: { padding, fill: blueGrey700 },
q3Label: baseLabelStyles
}
}, baseProps),
candlestick: assign({
style: {
data: {
Expand Down Expand Up @@ -138,6 +152,19 @@ export default {
group: assign({
colorScale: colors
}, baseProps),
legend: {
colorScale: colors,
gutter: 10,
orientation: "vertical",
titleOrientation: "top",
style: {
data: {
type: "circle"
},
labels: baseLabelStyles,
title: assign({}, baseLabelStyles, { padding: 5 })
}
},
line: assign({
style: {
data: {
Expand Down Expand Up @@ -200,18 +227,5 @@ export default {
pointerEvents: "none"
}
}
}, baseProps),
legend: {
colorScale: colors,
gutter: 10,
orientation: "vertical",
titleOrientation: "top",
style: {
data: {
type: "circle"
},
labels: baseLabelStyles,
title: assign({}, baseLabelStyles, { padding: 5 })
}
}
}, baseProps)
};