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

Include option for padAngle on RadialChart #920

Merged
merged 7 commits into from
Aug 21, 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
4 changes: 4 additions & 0 deletions docs/arc-series.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Type: `string|number`
Default: 1
The opacity of an arc in the series, from 0 (transparent) to 1 (opaque).

#### padAngle (optional)
Type: `number|function`
The padding to be applied between arcs.

<!-- INJECT:"ClockExampleWithLink" -->

## Series API Reference
Expand Down
4 changes: 4 additions & 0 deletions docs/radial-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ SVG paths (which is what the arc series is made up of) have numerous manipulable
Type: `string`
The className to be added to an individual arc in the series.

#### padAngle (optional)
Type: `number|function`
The padding to be applied between arcs. See above donut chart for an example of a padded angle.

## Api

##### angleDomain, angleRange, angleType
Expand Down
4 changes: 4 additions & 0 deletions docs/sunburst.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,7 @@ Type: `function`
- Should accept arguments (arc node, domEvent)

Pass in a function that will be called on mouseOut on a given arc.

#### padAngle (optional)
Type: `number|function`
The padding to be applied between arcs.
3 changes: 2 additions & 1 deletion showcase/radial-chart/donut-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export default class SimpleRadialChart extends Component {
onValueMouseOver={v => this.setState({value: v})}
onSeriesMouseOut={v => this.setState({value: false})}
width={300}
height={300}>
height={300}
padAngle={0.04} >
{value && <Hint value={value}/>}
</RadialChart>
);
Expand Down
3 changes: 2 additions & 1 deletion showcase/sunbursts/sunburst-with-tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export default class SunburstWithTooltips extends React.Component {
getLabel={d => d.name}
getSize={d => d.bigness}
getColor={d => d.clr}
width={350}>
width={350}
padAngle={() => 0.02}>
{hoveredCell ? <Hint value={buildValue(hoveredCell)}>
<div style={tipStyle}>
<div style={{...boxStyle, background: hoveredCell.clr}}/>
Expand Down
12 changes: 9 additions & 3 deletions src/plot/series/arc-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const defaultProps = {
center: {x: 0, y: 0},
arcClassName: '',
className: '',
style: {}
style: {},
padAngle: 0
};

/**
Expand Down Expand Up @@ -127,6 +128,7 @@ class ArcSeries extends AbstractSeries {
hideSeries,
marginLeft,
marginTop,
padAngle,
style
} = this.props;

Expand Down Expand Up @@ -179,7 +181,7 @@ class ArcSeries extends AbstractSeries {
startAngle: angle0(row) || 0,
endAngle: angle(row)
};
const arcedData = arcBuilder();
const arcedData = arcBuilder().padAngle(padAngle);
const rowStyle = row.style || {};
const rowClassName = row.className || '';
return (<path {...{
Expand Down Expand Up @@ -211,7 +213,11 @@ ArcSeries.propTypes = {
x: PropTypes.number,
y: PropTypes.number
}),
arcClassName: PropTypes.string
arcClassName: PropTypes.string,
padAngle: PropTypes.oneOfType([
PropTypes.function,
PropTypes.number
])
};
ArcSeries.defaultProps = defaultProps;
ArcSeries.displayName = 'ArcSeries';
Expand Down
5 changes: 5 additions & 0 deletions src/radial-chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ RadialChart.propTypes = {
).isRequired,
getAngle: PropTypes.func,
getAngle0: PropTypes.func,
padAngle: PropTypes.oneOfType([
PropTypes.function,
PropTypes.number
]),
getRadius: PropTypes.func,
getRadius0: PropTypes.func,
getLabel: PropTypes.func,
Expand All @@ -210,6 +214,7 @@ RadialChart.defaultProps = {
className: '',
colorType: 'category',
colorRange: DISCRETE_COLOR_RANGE,
padAngle: 0,
getAngle: d => d.angle,
getAngle0: d => d.angle0,
getRadius: d => d.radius,
Expand Down
9 changes: 7 additions & 2 deletions src/sunburst/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ Sunburst.propTypes = {
onValueMouseOver: PropTypes.func,
onValueMouseOut: PropTypes.func,
getSize: PropTypes.func,
width: PropTypes.number.isRequired
width: PropTypes.number.isRequired,
padAngle: PropTypes.oneOfType([
PropTypes.function,
PropTypes.number
])
};
Sunburst.defaultProps = {
getAngle: d => d.angle,
Expand All @@ -215,7 +219,8 @@ Sunburst.defaultProps = {
getColor: d => d.color,
hideRootNode: false,
getLabel: d => d.label,
getSize: d => d.size
getSize: d => d.size,
padAngle: 0
};

export default Sunburst;
3 changes: 2 additions & 1 deletion tests/components/radial-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const RADIAL_PROPS = {
],
height: 300,
showLabels: true,
width: 400
width: 400,
padAngle: 0.3
};
// make sure that the components render at all
testRenderWithProps(RadialChart, RADIAL_PROPS);
Expand Down