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

Bar Chart colors

Open ahmedu007 opened this issue 7 years ago • 8 comments

Hi,

Thanks for the amazing Library, it looks really nice and performs well too. Just a question. Is there a way to change the colours of the individual barchats instead of rendering them uniformly in 1 color?

e.g: let sampleData = [ { seriesName: 'test2', data: [140, 160], color: [colors.lightNavy, colors.Red], }, ];

So that both the charts have their own individual colors?. I've tried passing primaryColor, secondary and other props, but nothing seems to be working. Any help or advice would be appreciated.

Thanks

ahmedu007 avatar May 10 '18 10:05 ahmedu007

@ahmedu007

Thank you for using react native pure chart.

we can only one color by one series.

if you want to individual color by data, you should split data by multi series.

kingwang09 avatar May 10 '18 10:05 kingwang09

Thankyou @kingwang09 for such a quick response. I've tried that, but then the width of the bars get really narrow. I only have 2 bars to render on the whole screen so I need them to be quite wide. i've set the defaultColumnWidth to 500 and it works, but is there a way to give a gap in the middle of the two bars?

ahmedu007 avatar May 10 '18 10:05 ahmedu007

@ahmedu007

can i show your applied screen?

kingwang09 avatar May 10 '18 11:05 kingwang09

if you want to give a gap in the middle of the two bars, can you try using defaultColumnMargin? (not try using defaultColumnWidth)

kingwang09 avatar May 10 '18 11:05 kingwang09

simulator screen shot - iphone 8 plus - 2018-05-10 at 12 30 05

<PureChart
            height={height(55.2)}
            defaultColumnWidth={width(50)}
            data={sampleData}
            defaultColumnMargin={40}
            type="bar"
            numberOfYAxisGuideLine={5}
            backgroundColor="rgba(0,0,0,0.5)"
            // highlightColor="yellow"
            // primaryColor="blue"
          />

So this is what I want to do. 2 different bars with different colours. I've tried using defaultColumnMargin as you suggested already, but your default right margin for the 0 index is set to 0 in the source code. Ideally if there is a prop that can be set on individual charts it would be perfect.

@kingwang09

ahmedu007 avatar May 10 '18 11:05 ahmedu007

i understand what you mean. we'll try implement individual column gap until next release.

thanks for using our charts. :)

kingwang09 avatar May 10 '18 12:05 kingwang09

Thankyou. Ideally if you can implement a way to pass a colour prop to individual bar charts (not a multiSeries) that would be awesome

ahmedu007 avatar May 10 '18 12:05 ahmedu007

How to set different colors for all bars in single series.https://www.google.com/url?sa=i&url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F50501714%2Frender-bar-chart-with-different-colors-in-react-native&psig=AOvVaw3MfiJGIYYyk5GobB1xP9zh&ust=1588427154810000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCJi_89bmkukCFQAAAAAdAAAAABAI

JP6720 avatar May 01 '20 13:05 JP6720