Giter Club home page Giter Club logo

Comments (9)

jasondavies avatar jasondavies commented on May 18, 2024

Apologies for the lack of documentation. The padding option is indeed a boolean. It simply extends the word silhouettes by one pixel in all directions. If you need arbitrary padding, you can achieve this by simply using a smaller font size when rendering the words. I have found that a font size of 1px smaller works well for the output.

from d3-cloud.

Thinkscape avatar Thinkscape commented on May 18, 2024

Just stumbled upon that and tried to work around it, but failed.

Unfortunately the font size trick doesn't work too well, because of apostrophes, smaller words being put inside empty spaces of bigger words and other effects of the layout algo. Using font difference more than 1px will produce a broken layout with overlapping words :-(

from d3-cloud.

jasondavies avatar jasondavies commented on May 18, 2024

Works fine for me. Are you sure you are positioning the words correctly? Perhaps you could post an example.

from d3-cloud.

Thinkscape avatar Thinkscape commented on May 18, 2024

Here's an example with 5px difference. Notice the business mixer phrase - you can clearly see that the b character would fit in the gap left to talent word. Unfortunately, after decreasing font size and after it re-centers and reduces it's size proportionally, the distances between letters also decrease proportionally, thus making the word more "compact" (and also shorter).

image

from d3-cloud.

Thinkscape avatar Thinkscape commented on May 18, 2024

And here's an example without font size manipulation:
screen shot 2013-06-18 at 6 04 37 pm

from d3-cloud.

Thinkscape avatar Thinkscape commented on May 18, 2024

Oh jolly! You're the best Jason! :-)
I'll test it out in a few minutes...

I'll give back by PR-ing some of my enhancements, including deterministic cloud generation ;-)

from d3-cloud.

jasondavies avatar jasondavies commented on May 18, 2024

Excellent. :)

from d3-cloud.

Thinkscape avatar Thinkscape commented on May 18, 2024

That stroke trick was ingenius ;-) Congratulations on the idea...

However there's noticeable performance hit after enabling padding... I can't benchmark it further but I'd say about 20% performance loss as compared to stroke-less bitmap+layout generation.

from d3-cloud.

jasondavies avatar jasondavies commented on May 18, 2024

This will only impact the performance of the initial sprite grab, which is not a bottleneck. If you are comparing padding=0 with something like padding=5, then it will of course take longer to find a layout because the text is bigger; a better comparison would be (padding=0, font-size=X) and (padding=5, font-size=X-5). The layout algorithm itself is unchanged.

from d3-cloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.