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

Is there a way to change the color and font in case of Tag cloud chart? #10

Closed
fightaadeshfight opened this issue May 23, 2018 · 12 comments

Comments

@fightaadeshfight
Copy link

No description provided.

@Shestac92
Copy link

@fightaadeshfight
Can you elaborate, please, how do you want to apply colors and font? According which value/condition? Many options available here.

@fightaadeshfight
Copy link
Author

Like right now the text is picking random colors. I wanted to create my own set of colors which will be picked at random(there is no condition for it). I just want different shades.

For font i just want a different font for the complete chart.(Again, no conditions applied.)

@Shestac92
Copy link

Shestac92 commented May 24, 2018

@fightaadeshfight
You can define your own custom palette and the tag cloud will take colours from that palette.
You can implement it like this:

OrdinalColor ordinalColor = new OrdinalColor();
ordinalColor.setColors(new String[] { "#000000", "#f18126", "#3b8ad8", "#00ff00", "#ff0000" });
tagCloud.setColorScale(ordinalColor);

Font you can apply like this:

TagCloud.getNormal().setFontFamily("Helvetica");
tagCloud.getNormal().setFontSize(8);
tagCloud.getSelected().setFontStyle(TextFontStyle.ITALIC);

@fightaadeshfight
Copy link
Author

Can i add my custom font family(like in the form of ttf or otf file in android) or i can only choose from the ones already defined?

@Shestac92
Copy link

Shestac92 commented May 25, 2018

@fightaadeshfight
Yes! Now it's possible.
You can do it like this:

anyChartView.addFont("Pacifico", "file:///android_asset/Pacifico.ttf");
tagCloud.getNormal().setFontFamily("Pacifico");

And the Pacifico.ttf file should be located in assets.

We have just updated the library to implement this feature. Please, download the latest version to enable this feature.

@fightaadeshfight
Copy link
Author

Do i need to download the jar file? The new dependency does not seem to work

@Shestac92
Copy link

@fightaadeshfight
Can you specify how you include dependencies? With Gradle or any other tool?

@fightaadeshfight
Copy link
Author

with gradle. The old dependency
compile 'com.github.AnyChart:AnyChart-Android:0.1.9'

is working fine.

But when i change it to new version it stops working.

@Shestac92
Copy link

@fightaadeshfight
ok, I see. Can you share with us the error log by Gradle?

@fightaadeshfight
Copy link
Author

its working now. it wasn't a few hours earlier. maybe the mirrors were not updated or something. Thanks anyways.

@fightaadeshfight
Copy link
Author

I gave the ordinal colors as you said

 OrdinalColor ordinalColor = new OrdinalColor();
    ordinalColor.setColors(new String[] { "#3A3042", "#DB9D47", "#FF784F", "#5BC0EB", "#3C91E6", "#325060", "#6E8898", "#9FB1BC", "#E6EDE9", "#E2C044"});
   
 
    cloud.setColorScale(ordinalColor);

But it picks a 4 colors for the big words. rest are same. Is there a limit to colors that i can give? And if the items in the list is around 10 only one color is shown.

@fightaadeshfight
Copy link
Author

I figure it out. The colors were distributed according to category. So if i do not define any category the colors get distributed via range. So, i defined an array of categories and added them at random and hence the colors were chosen at random.

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

No branches or pull requests

2 participants