From 21a7c0ea5dccd6719404bbc64e1e33921cd89e0c Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 1 Feb 2021 17:21:09 +0100 Subject: [PATCH] Support custom Y labels in StackedBarChart --- App.js | 19 +++++++++++++++++++ src/StackedBarChart.tsx | 10 ++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/App.js b/App.js index 4165be5c..8c31b6d5 100644 --- a/App.js +++ b/App.js @@ -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", @@ -172,6 +178,19 @@ export default class App extends React.Component { height={220} chartConfig={chartConfig} /> + + Stacked Bar Graph with custom Y labels + + { + return +input * 2; + }} + /> Stacked Bar Graph Percentile string; } type StackedBarChartState = {}; @@ -184,7 +186,10 @@ class StackedBarChart extends AbstractChart< withVerticalLabels = true, segments = 4, decimalPlaces, - percentile = false + percentile = false, + formatYLabel = (yLabel: string) => { + return yLabel; + } } = this.props; const { borderRadius = 0 } = style; @@ -240,7 +245,8 @@ class StackedBarChart extends AbstractChart< data: [0, border], paddingTop, paddingRight, - decimalPlaces + decimalPlaces, + formatYLabel }) : null}