New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set one particular bar's color #1662

Closed
kamal250 opened this Issue Apr 7, 2016 · 8 comments

Comments

Projects
None yet
5 participants
@kamal250

kamal250 commented Apr 7, 2016

Hello Philipp,

I have added data to barchart as:

`for(int i=0;i<10;i++){
xVals.add(i);
yVals1.add(new BarEntry(i*10, i));
}

BarDataSet set1 = new BarDataSet(yVals1, "Number");
ArrayList dataSets1 = new ArrayList();
dataSets1.add(set1);
BarData data = new BarData(xVals, dataSets1);
mChart.setData(data);`

Now my question is that: if I want to change the bar color of 2nd and last bar, then how can I change it?

@PhilJay

This comment has been minimized.

Owner

PhilJay commented Apr 7, 2016

if(index == specificIndex) colors.add(Color);
else colors.add(NormalColor);

@PhilJay PhilJay closed this Apr 7, 2016

@kamal250

This comment has been minimized.

kamal250 commented Apr 7, 2016

Can you please elaborate more?

@PhilJay

This comment has been minimized.

Owner

PhilJay commented Apr 7, 2016

Inside your for loop that adds the entries, place this code.

@kamal250

This comment has been minimized.

kamal250 commented Apr 7, 2016

Like this? set1.addColor(Color.parseColor("#878686"));

@kamal250

This comment has been minimized.

kamal250 commented Apr 7, 2016

Thanks, it is working.

@hi-manshu

This comment has been minimized.

hi-manshu commented Feb 28, 2018

the above code didn't work for me.
i Tried
if (j == 6) {
Bardataset.setColors(new int[]{Color.parseColor("#2DC9D7")});
Bardataset.setHighLightColor(Color.parseColor("#2DC9D7"));
} else {
Bardataset.setColor(Color.parseColor("#000000"));
Bardataset.setHighLightColor(Color.parseColor("#000000"));
}

@nimish17

This comment has been minimized.

nimish17 commented May 16, 2018

@PhilJay can you please help me for reduce space between bars? i need remove space between all bars

@almic

This comment has been minimized.

Collaborator

almic commented May 19, 2018

@hi-manshu and @nimish17 please do not necropost of such old issues, especially not with useless comments like code spam and off-topic questions.

Repository owner locked as off topic and limited conversation to collaborators May 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.