Skip to content

Commit

Permalink
feat(pie): homogeneize sliceLabels properties
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Nov 4, 2020
1 parent ed176a9 commit 19444c7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
8 changes: 4 additions & 4 deletions packages/pie/src/Pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const Pie = ({
// slices labels
sliceLabel,
enableSlicesLabels,
slicesLabelsSkipAngle,
slicesLabelsTextColor,
sliceLabelsSkipAngle,
sliceLabelsTextColor,

// styling
defs,
Expand Down Expand Up @@ -178,8 +178,8 @@ const Pie = ({
innerRadius={innerRadius}
theme={theme}
label={getSliceLabel}
skipAngle={slicesLabelsSkipAngle}
textColor={getInheritedColorGenerator(slicesLabelsTextColor, theme)}
skipAngle={sliceLabelsSkipAngle}
textColor={getInheritedColorGenerator(sliceLabelsTextColor, theme)}
/>
</g>
)
Expand Down
9 changes: 5 additions & 4 deletions packages/pie/src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export const PiePropTypes = {
// slices labels
enableSlicesLabels: PropTypes.bool.isRequired,
sliceLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
slicesLabelsSkipAngle: PropTypes.number,
slicesLabelsTextColor: inheritedColorPropType.isRequired,
sliceLabelsSkipAngle: PropTypes.number,
sliceLabelsTextColor: inheritedColorPropType.isRequired,

// styling
colors: ordinalColorsPropType.isRequired,
Expand Down Expand Up @@ -134,8 +134,9 @@ export const PieDefaultProps = {

// slices labels
enableSlicesLabels: true,
sliceLabel: 'value',
slicesLabelsTextColor: { theme: 'labels.text.fill' },
sliceLabel: 'formattedValue',
sliceLabelsSkipAngle: 0,
sliceLabelsTextColor: { theme: 'labels.text.fill' },

// styling
colors: { scheme: 'nivo' },
Expand Down
20 changes: 11 additions & 9 deletions website/src/data/components/pie/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,22 +411,24 @@ const props = [
'Defines how to get label text, can be a string (used to access current node data property) or a function which will receive the actual node data.',
type: 'string | Function',
required: false,
defaultValue: 'value',
defaultValue: defaults.sliceLabel,
controlType: 'choices',
group: 'Slices labels',
controlOptions: {
choices: ['id', 'value', `d => \`\${d.id} (\${d.value})\``].map(choice => ({
label: choice,
value: choice,
})),
choices: ['id', 'value', 'formattedValue', `d => \`\${d.id} (\${d.value})\``].map(
choice => ({
label: choice,
value: choice,
})
),
},
},
{
key: 'slicesLabelsSkipAngle',
key: 'sliceLabelsSkipAngle',
help: `Skip label if corresponding slice's angle is lower than provided value.`,
type: 'number',
required: false,
defaultValue: 0,
defaultValue: defaults.sliceLabelsSkipAngle,
controlType: 'range',
group: 'Slices labels',
controlOptions: {
Expand All @@ -437,11 +439,11 @@ const props = [
},
},
{
key: 'slicesLabelsTextColor',
key: 'sliceLabelsTextColor',
help: 'Defines how to compute slice label text color.',
type: 'string | object | Function',
required: false,
defaultValue: defaults.slicesLabelsTextColor,
defaultValue: defaults.sliceLabelsTextColor,
controlType: 'inheritedColor',
group: 'Slices labels',
},
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/pie/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ const initialProperties = {

enableSlicesLabels: true,
sliceLabel: 'value',
slicesLabelsSkipAngle: 10,
slicesLabelsTextColor: '#333333',
sliceLabelsSkipAngle: 10,
sliceLabelsTextColor: '#333333',

animate: true,
motionStiffness: 90,
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/pie/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const initialProperties = {

enableSlicesLabels: true,
sliceLabel: 'value',
slicesLabelsSkipAngle: 10,
slicesLabelsTextColor: '#333333',
sliceLabelsSkipAngle: 10,
sliceLabelsTextColor: '#333333',

animate: true,
motionStiffness: 90,
Expand Down

0 comments on commit 19444c7

Please sign in to comment.