diff --git a/src/components/charts/pie/Pie.js b/src/components/charts/pie/Pie.js index 8f038470a..d8af2626e 100644 --- a/src/components/charts/pie/Pie.js +++ b/src/components/charts/pie/Pie.js @@ -94,7 +94,7 @@ export default class Pie extends Component { // theming theme: {}, - colors: Nivo.defaults.colorRange, + colors: 'nivo', colorBy: 'id', // motion diff --git a/src/components/charts/pie/PieRadialLabels.js b/src/components/charts/pie/PieRadialLabels.js index 3a51eae84..7ded89ad0 100644 --- a/src/components/charts/pie/PieRadialLabels.js +++ b/src/components/charts/pie/PieRadialLabels.js @@ -98,6 +98,7 @@ export default class PieRadialLabels extends Component { { - serie.data.forEach(d => { + serie.data.forEach((d, i) => { const barWidth = xScale.bandwidth() / data.length const x = xScale(d.x) + barWidth * serieIndex const y = yScale(d.y) @@ -79,7 +79,7 @@ export const generateGroupedBars = (data, width, height, color, { xPadding = 0 } if (barWidth > 0 && barHeight > 0) { bars.push({ - key: `${serie.id}.${d.x}`, + key: `${serie.id}.${i}`, value, x, y, @@ -133,7 +133,7 @@ export const generateStackedBars = (data, width, height, color, { xPadding = 0 } const bars = [] stackedData.forEach(serie => { - serie.data.forEach(d => { + serie.data.forEach((d, i) => { const x = xScale(d.x) const barWidth = xScale.bandwidth() const y = yScale(d.y1) @@ -143,7 +143,7 @@ export const generateStackedBars = (data, width, height, color, { xPadding = 0 } if (barWidth > 0 && barHeight > 0) { bars.push({ - key: `${serie.id}.${d.x}`, + key: `${serie.id}.${i}`, value, x, y, diff --git a/stories/charts/pie.stories.js b/stories/charts/pie.stories.js new file mode 100644 index 000000000..5d3c81fe3 --- /dev/null +++ b/stories/charts/pie.stories.js @@ -0,0 +1,95 @@ +import React from 'react' +import { storiesOf } from '@storybook/react' +import { withKnobs, select } from '@storybook/addon-knobs' +import { generateProgrammingLanguageStats } from 'nivo-generators' +import '../style.css' +import { Pie } from '../../src' + +const commonProperties = { + width: 600, + height: 600, + margin: { top: 80, right: 120, bottom: 80, left: 120 }, + data: generateProgrammingLanguageStats(true, 9).map(d => ({ + id: d.label, + ...d, + })), + animate: true, +} + +const stories = storiesOf('Pie', module) + +stories + .addDecorator(story => +
+ {story()} +
+ ) + .addDecorator(withKnobs) + +stories.add('default', () => ) + +stories.add('donut', () => ) + +stories.add('fancy slices', () => + +) + +stories.add('custom radial label', () => + `${d.id}: ${d.value}`} + radialLabelsLinkColor="inherit" + radialLabelsLinkStrokeWidth={3} + radialLabelsTextColor="inherit:darker(1.2)" + enableSlicesLabels={false} + /> +) + +/* +stories.add('with custom curve', () => + +) + +stories.add('linear grid shape', () => + +) + +stories.add('with markers label', () => + +) + +stories.add('abusing markers label', () => + +) +*/