0

Is this possible using the onPress event can change the bar chart's particular bars colour or styles?

https://github.com/JesperLekland/react-native-svg-charts

Anybody, please help me.

EDISON J
  • 324
  • 3
  • 12

1 Answers1

0

You should try to put the color or style in the state, and then in the onPress change it. And then the changes will be reflected:

onPress={()=> this.setState({colors: ['#7b4173', '#a55194', '#ce6dbd', '#de9ed6']})

And in the StackedBarChart, for Example, insert as a prop:

  <StackedBarChart
            style={{ height: 200 }}
            keys={keys}
            colors={this.state.colors}
            data={data}
            showGrid={false}
            contentInset={{ top: 30, bottom: 30 }}
        />
David Vittori
  • 1,146
  • 1
  • 13
  • 30
  • Thank you for your response. I want to change a particular bar colour only which bar I pressed. Is it possible on the bar chart? – EDISON J Oct 15 '19 at 05:27