zverok / magic_cloud

Simple pretty word cloud for Ruby
MIT License
85 stars 27 forks source link

Error when using MagicCloud on view #12

Closed Francklepanda closed 7 years ago

Francklepanda commented 7 years ago

Hello

when I try to use MagicCloud::Cloud.new(words, rotate: :free, scale: :log) it shows me # on my view

how can I use it ? will it create an image and I should use image_tag ? sorry for this question I think I didn't understand something ^^

Franck

zverok commented 7 years ago

MagicCloud is a standalone Ruby library, it knows nothing about Rails. So, your typical workflow to show it in Rails view is:

  1. Create cloud with cloud = MagicCloud::Cloud.new(...)
  2. Draw it: img = cloud.draw(width, height)
  3. Save it: img.write('some_name.png')
  4. Use the created file in image tag: image_tag 'some_name.png'

Note, that it will produce static cloud image (which is the target of the library). If you need a pretty JS word cloud, clickable and recizable, consider using d3.js and https://github.com/jasondavies/d3-cloud

Francklepanda commented 7 years ago

Thanks a lot ! I don't understand why I have some words who disappear :/

my code is :

and the result : some_name

Thanks for https://github.com/jasondavies/d3-cloud I think I will use that to have clickable words :)

zverok commented 7 years ago

I don't understand why I have some words who disappear :/

Its because magic cloud is dumb (I didn't have enough time recently to update it): it calculates long words size with default font, sees it is too huge for the image size and just drops them. Try larger image size...