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 it possible to customize the d3 cloud through android programmatically? #3

Open
yummyummyummy opened this issue Dec 14, 2017 · 2 comments

Comments

@yummyummyummy
Copy link

Hi
I am trying to attach d3 word cloud in my android app.
To support many kinds of android devices, I wanna optimize the word cloud's size programmatically.
Also, fontSize and color of each words.
Can you give me any hints? I am not really familiar with js so it is very difficult for me.
Thank you.

@rbarbantan
Copy link
Owner

All the logic in done in d3.js (https://d3js.org/). There really is no way around it. You can compute some of the values (like the size) in java/android and pass them as parameters, just like you pass the "wordCloud" in MainActivity.
For example, replace change the StringBuilder to include other params, like:
sb.append("], 300)");
and in javascript, replace the hardcoded values with variables:

function wordCloud(data, cloudSize) {
    var fill = d3.scale.category20();
    var layout = d3.layout.cloud().size([cloudSize, cloudSize ])
...

@yummyummyummy
Copy link
Author

Thank you so much.
It helped me a lot

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