Skip to content
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

[Feature] Multiple gradient color for barchart #4001

Merged
merged 1 commit into from
May 5, 2018

Conversation

oatrice
Copy link
Contributor

@oatrice oatrice commented May 3, 2018

image

image

-set mutiple gradient color for barchart

How to use.

int startColor1 = ContextCompat.getColor(this, android.R.color.holo_orange_light);
int startColor2 = ContextCompat.getColor(this, android.R.color.holo_blue_light);
int startColor3 = ContextCompat.getColor(this, android.R.color.holo_orange_light);
int startColor4 = ContextCompat.getColor(this, android.R.color.holo_green_light);
int startColor5 = ContextCompat.getColor(this, android.R.color.holo_red_light);
int endColor1 = ContextCompat.getColor(this, android.R.color.holo_blue_dark);
int endColor2 = ContextCompat.getColor(this, android.R.color.holo_purple);
int endColor3 = ContextCompat.getColor(this, android.R.color.holo_green_dark);
int endColor4 = ContextCompat.getColor(this, android.R.color.holo_red_dark);
int endColor5 = ContextCompat.getColor(this, android.R.color.holo_orange_dark);

List<GradientColor> gradientColors = new ArrayList<>();
gradientColors.add(new GradientColor(startColor1, endColor1));
gradientColors.add(new GradientColor(startColor2, endColor2));
gradientColors.add(new GradientColor(startColor3, endColor3));
gradientColors.add(new GradientColor(startColor4, endColor4));
gradientColors.add(new GradientColor(startColor5, endColor5));

set1.setGradientColors(gradientColors);

You can use this feature by add dependency of my fork this repository.

  • Add the following to your project level build.gradle:
allprojects {
	repositories {
		maven { url "https://jitpack.io" }
	}
}
  • Add this to your app build.gradle:
dependencies {
	implementation 'com.github.oatrice:MPAndroidChart:3.0.5'
}

@Skarmm
Copy link

Skarmm commented May 4, 2018

Hi, small issue here but what object is your set1 in the example. I've tried calling setGradientColors with BarDataSet it doesn't have that method.

EDIT: Forgot to remove the original implementation mpchart from my gradle, everything works now!

@oatrice
Copy link
Contributor Author

oatrice commented May 4, 2018

@Skarmm
Did you use implementation 'com.github.oatrice:MPAndroidChart:3.0.5' ?

You can check detail of set1 by clone my fork this repo.
https://github.com/oatrice/MPAndroidChart/tree/feature/muti_gradient

branch: feature/muti_gradient or tag: 3.0.5

@almic
Copy link
Contributor

almic commented May 5, 2018

@oatrice Hey, sorry for the late response. I was hoping you would just add secondary colors instead of a brand new class, but this works fine for now. Merging.

@almic almic merged commit c08ec81 into PhilJay:master May 5, 2018
@oatrice oatrice deleted the feature/muti_gradient branch May 6, 2018 07:59
@shekibobo
Copy link

Any chance of having a release with this feature pushed out soon?

regas99 pushed a commit to regas99/MPAndroidChart that referenced this pull request Apr 1, 2019
[Feature] Multiple gradient color for barchart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants