react-native-chart-kit icon indicating copy to clipboard operation
react-native-chart-kit copied to clipboard

How can we add different bar color in barChart?

Open sreejithexp opened this issue 6 years ago β€’ 6 comments

How can we add different bar Color in barChart?

sreejithexp avatar Sep 19 '19 17:09 sreejithexp

This was a quite long ago, but to change the color from all the bars in the chart you can use color, fillShadowGradient and fillShadowGradientOpacity props of the ChartConfig as described here. Example:

const chartConfig = {
  backgroundGradientFrom: '#fff',
  backgroundGradientFromOpacity: 0,
  backgroundGradientTo: '#fff',
  backgroundGradientToOpacity: 0.5,
  color: () => '#333', // THIS
  strokeWidth: 2,
  barPercentage: 0.5,
  propsForLabels: {
    fontSize: '10',
  },
  fillShadowGradient: '#FF493B', // THIS
  fillShadowGradientOpacity: 1, // THIS
};

But if you want to change the color of only one bar I don't think it's possible right now(not that I know of) πŸ˜„ .

vitorverasm avatar Nov 17 '19 00:11 vitorverasm

@sreejithexp I did it using

withCustomBarColorFromData={true} flatColor={true}

and also sending array of colors

image

image

MoraesGil avatar Jun 05 '21 02:06 MoraesGil

@sreejithexp I did it using

withCustomBarColorFromData={true} flatColor={true}

and also sending array of colors

image

image

WOOOAAAHHHHHH !!!!! It worked πŸ₯‡ πŸ‘

Aurangempire avatar Jun 07 '21 13:06 Aurangempire

@sreejithexp I did it using

withCustomBarColorFromData={true} flatColor={true}

and also sending array of colors

image

image

It worked! πŸ‘

khdealwis avatar May 20 '22 11:05 khdealwis

its worked! tq

SethuSS avatar Mar 08 '23 13:03 SethuSS

@sreejithexp I did it using

withCustomBarColorFromData={true} flatColor={true}

and also sending array of colors

image

image

Thank you πŸ™ŒπŸ½

oluwatobimaxwell avatar Jul 09 '23 11:07 oluwatobimaxwell