Skip to content

Commit

Permalink
Include option for padAngle on RadialChart (#920)
Browse files Browse the repository at this point in the history
* add padAngle functionality

* remove trailing comma

* include padAngle in sunburst

* include padangle in sunburst docs

* include padAngle in simple donut chart showcase

* includ clarification text to radial-chart.md

* include padAngle as function in sunburstWithTooltips
  • Loading branch information
Devin Rasmussen authored and mcnuttandrew committed Aug 21, 2018
1 parent a679eee commit 17d7969
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 8 deletions.
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

0 comments on commit 17d7969

Please sign in to comment.