diff --git a/demos/pie.png b/demos/pie.png new file mode 100644 index 0000000..ae03e8a Binary files /dev/null and b/demos/pie.png differ diff --git a/docs/PieChart/PieChartProps.md b/docs/PieChart/PieChartProps.md index 9c124a0..cf727c0 100644 --- a/docs/PieChart/PieChartProps.md +++ b/docs/PieChart/PieChartProps.md @@ -4,6 +4,7 @@ | -------------------- | -------------- | --------------------------------------------------------------------------------------------------------- | --------------- | | data | Array of items | An item object represents a section in the Pie chart. Descibed in the next table | \_ | | radius | number | Radius of the Pie chart | 120 | +| initialAngle | number | Starting angle in radians (illustrated below this table) | 0 | | isThreeD | Boolean | If set to true, it rotates and translates the chart to give it a 3D effect | false | | shadow | Boolean | Shadow to the Pie chart, when set to true, it enhances the 3D effect | false | | shadowColor | ColorValue | Color of the shadow | lightgray | @@ -24,6 +25,11 @@ | centerLabelComponent | Function | Component to be rendered at the center of the Pie chart | \_ | | semiCircle | Boolean | When set to true, renders the Pie Chart in a semi-circle. donut semiCircle charts look like a speed-meter | false | +#### initialAngle + +The default value is 0. The angles are distributed differently from the usual coordinate system. It is illustrated below- + + ### Item description | Prop | Type | Description | diff --git a/src/BarChart/RenderBars.tsx b/src/BarChart/RenderBars.tsx index 6e0546a..cf44bbb 100644 --- a/src/BarChart/RenderBars.tsx +++ b/src/BarChart/RenderBars.tsx @@ -111,7 +111,9 @@ const RenderBars = (props: Props) => { } = props; const barMarginBottom = - item.barMarginBottom === 0 ? 0 : props.barMarginBottom || 0; + item.barMarginBottom === 0 + ? 0 + : item.barMarginBottom || props.barMarginBottom || 0; const renderLabel = (label: String, labelTextStyle: any, value: number) => { return ( diff --git a/src/PieChart/index.tsx b/src/PieChart/index.tsx index aeda553..18a296b 100644 --- a/src/PieChart/index.tsx +++ b/src/PieChart/index.tsx @@ -34,6 +34,7 @@ type propTypes = { centerLabelComponent?: Function; tilt?: number; + initialAngle?: number; }; type itemType = { value: number; @@ -96,6 +97,7 @@ export const PieChart = (props: propTypes) => { '800', '900', ]; + const initialAngle = props.initialAngle || 0; let isDataShifted = false; data.forEach((item: any) => { @@ -148,7 +150,7 @@ export const PieChart = (props: propTypes) => { /******************************************************/ let i = 0, - angleSum = 0; + angleSum = initialAngle; let colors = [ 'cyan', 'green',