Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const chartConfigs = [
backgroundGradientTo: "#ffffff",
color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`
},
{
backgroundColor: "#ffffff",
backgroundGradientFrom: "#ffffff",
backgroundGradientTo: "#ffffff",
color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`
},
{
backgroundColor: "#26872a",
backgroundGradientFrom: "#43a047",
Expand Down Expand Up @@ -172,6 +178,19 @@ export default class App extends React.Component {
height={220}
chartConfig={chartConfig}
/>
<Text style={labelStyle}>
Stacked Bar Graph with custom Y labels
</Text>
<StackedBarChart
style={graphStyle}
data={stackedBarGraphData}
width={width}
height={220}
chartConfig={chartConfig}
formatYLabel={input => {
return +input * 2;
}}
/>
<Text style={labelStyle}>Stacked Bar Graph Percentile</Text>
<StackedBarChart
style={graphStyle}
Expand Down
8 changes: 7 additions & 1 deletion src/StackedBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export interface StackedBarChartProps extends AbstractChartProps {
segments?: number;

percentile?: boolean;

formatYLabel?: (yLabel: string) => string;
}

type StackedBarChartState = {};
Expand Down Expand Up @@ -185,6 +187,9 @@ class StackedBarChart extends AbstractChart<
segments = 4,
decimalPlaces,
percentile = false,
formatYLabel = (yLabel: string) => {
return yLabel;
},
hideLegend = false
} = this.props;

Expand Down Expand Up @@ -242,7 +247,8 @@ class StackedBarChart extends AbstractChart<
data: [0, border],
paddingTop,
paddingRight,
decimalPlaces
decimalPlaces,
formatYLabel
})
: null}
</G>
Expand Down