Skip to content
Open
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
25 changes: 20 additions & 5 deletions src/StackedBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ export interface StackedBarChartProps extends AbstractChartProps {
data: StackedBarChartData;
width: number;
height: number;
/**
* Use for 90 degree verticalLabelRotation or extra height for chart
*/
extraHeight?: number;
chartConfig: AbstractChartConfig;
hideLegend: boolean;
hideLegend?: boolean;
hideLabels?: boolean;
style?: Partial<ViewStyle>;
barPercentage?: number;
decimalPlaces?: number;
Expand All @@ -46,6 +51,8 @@ export interface StackedBarChartProps extends AbstractChartProps {
/**
* The number of horizontal lines
*/
horizontalLabelRotation?: number;
verticalLabelRotation?: number;
segments?: number;

percentile?: boolean;
Expand Down Expand Up @@ -133,7 +140,7 @@ class StackedBarChart extends AbstractChart<
/>
);

if (!this.props.hideLegend) {
if (!this.props.hideLabels) {
ret.push(
<Text
key={Math.random()}
Expand Down Expand Up @@ -197,6 +204,10 @@ class StackedBarChart extends AbstractChart<
data,
withHorizontalLabels = true,
withVerticalLabels = true,
verticalLabelRotation = 0,
horizontalLabelRotation = 0,
hideLabels = false,
extraHeight = 0,
segments = 4,
decimalPlaces,
percentile = false,
Expand All @@ -210,7 +221,11 @@ class StackedBarChart extends AbstractChart<
const { borderRadius = 0 } = style;
const config = {
width,
height
height,
verticalLabelRotation,
horizontalLabelRotation,
hideLabels,
extraHeight
};

let border = 0;
Expand All @@ -234,14 +249,14 @@ class StackedBarChart extends AbstractChart<

return (
<View style={style}>
<Svg height={height} width={width}>
<Svg height={height + extraHeight} width={width}>
{this.renderDefs({
...config,
...this.props.chartConfig
})}
<Rect
width="100%"
height={height}
height={height + extraHeight}
rx={borderRadius}
ry={borderRadius}
fill="url(#backgroundGradient)"
Expand Down