scruffy question

Discussion in 'Ruby' started by remco.zwaan@gmail.com, Nov 5, 2007.

  1. Guest

    Hi

    installed scruffy...and put the code below in my controller.

    def show_img
    graph = Scruffy::Graph.new
    graph.title = "Comparative Agent Performance"
    graph.value_formatter =
    Scruffy::Formatters::percentage.new:)precision => 0)

    graph.add :stacked do |stacked|
    stacked.add :bar, 'remco', [30, 60, 49, 29, 100, 120]
    stacked.add :bar, 'peter', [120, 240, 0, 100, 140, 20]
    stacked.add :bar, 'femmie', [10, 10, 90, 20, 40, 10]
    end

    graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']

    send_data(graph.render:)width => 800, :as => 'PNG'), :type =>
    'image/png', :disposition=> 'inline')
    end


    In the view a placed...

    <img src="<%= url_for:)action => 'show_img') %>"/>

    But with no succes..

    In the generated HTML i get

    <img src="/users/show_img"/>


    What i am doing wrong???

    remco
    --
    Posted via http://www.ruby-forum.com/.
    , Nov 5, 2007
    #1
    1. Advertising

  2. Jacob Basham Guest

    I'm not familiar with what you are doing, but I'm pretty sure you need
    to save the file in a public directory. Save that path as a variable
    which you can use in the view.

    And on a side note, url_for:)action) just builds the relative path for
    the page show_img creates. url_for is for building relative links to
    other controllers and actions. These paths are not real paths in your
    public directory, they are virtual paths rails builds for you when you
    request them.

    The rails list would be your best bet for more in depth help.

    Jake

    On Nov 5, 2007, at 5:50 AM, Remco Swoany wrote:

    > Hi
    >
    > installed scruffy...and put the code below in my controller.
    >
    > def show_img
    > graph = Scruffy::Graph.new
    > graph.title = "Comparative Agent Performance"
    > graph.value_formatter =
    > Scruffy::Formatters::percentage.new:)precision => 0)
    >
    > graph.add :stacked do |stacked|
    > stacked.add :bar, 'remco', [30, 60, 49, 29, 100, 120]
    > stacked.add :bar, 'peter', [120, 240, 0, 100, 140, 20]
    > stacked.add :bar, 'femmie', [10, 10, 90, 20, 40, 10]
    > end
    >
    > graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
    >
    > send_data(graph.render:)width => 800, :as => 'PNG'), :type =>
    > 'image/png', :disposition=> 'inline')
    > end
    >
    >
    > In the view a placed...
    >
    > <img src="<%= url_for:)action => 'show_img') %>"/>
    >
    > But with no succes..
    >
    > In the generated HTML i get
    >
    > <img src="/users/show_img"/>
    >
    >
    > What i am doing wrong???
    >
    > remco
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    Jacob Basham, Nov 7, 2007
    #2
    1. Advertising

  3. Got Got Guest

    Hi,

    I have tested with :
    send_data(graph.render:)width => 800, :as => 'PNG', :to =>
    "#{RAILS_ROOT}" + "/public/images/test.png"), :type =>'image/png',
    :disposition => 'inline')

    instead of :
    send_data(graph.render:)width => 800, :as => 'PNG'), :type =>
    'image/png', :disposition=> 'inline')

    But i have the same problem :
    app/controllers/supports_controller.rb:88: syntax error, unexpected
    tSTRING_BEG, expecting $end
    end',gfd :disposition=> 'inline')
    ^

    I can't understand !!!

    Who can help me to use Scruffy with RoR ?

    Got
    --
    Posted via http://www.ruby-forum.com/.
    Got Got, Dec 13, 2007
    #3
  4. -- Got Guest

    Hi,

    Finally, I'm trying to test Scruffy in my 'application_helper.rb' :

    def render_scruffy_graph
    graph = Scruffy::Graph.new
    graph.title = "Comparative Agent Performance"
    graph.value_formatter =
    Scruffy::Formatters::percentage.new:)precision => 0)
    graph.add :stacked do |stacked|
    stacked.add :bar, 'remco', [30, 60, 49, 29, 100, 120]
    stacked.add :bar, 'peter', [120, 240, 0, 100, 140, 20]
    stacked.add :bar, 'femmie', [10, 10, 90, 20, 40, 10]
    end
    graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
    graph.render:)width => 800, :as => 'PNG')
    end

    with :
    <%= render_scruffy_graph %> #in my 'show.rhtml' file

    But the image is returned as blob/string.

    So I've got something like that :
    >ÏŸ?�իW�k�.,[� ~��g��GD���VkD� AdM`` Æ�~��B�V�M{��M���[Ø¿���&��j� �'OFÅŠ�n��u��5����RÅŠÃסR��5k4T���S�xN!��ᨔ�(=�����W_aÊ”?���… c��}(V��Ŷ� cÇŽU��D� q 9�ڵk�ܹ�8p@���(]:Û·oC�޽�.:I`ժ�زe3Ê•+�tQ1h�@����T* 4P�9g����0aF��t8�|��V�p����GD�ï€Ó©R� ��� OOO�I]"�/_�U�V����x��9���P�\9����7y��1�mÞ¼>��۠,���n�EܸqÅ‹�̟��C� �ܹseʔ�(���xV�G�... D�-��7ß d�����hT�P>T:,��[�n� �ׯ��ѣrHHH@\\��E$�\� r*���8s� ��J�nݺ�=z����6�)S�46oÞ‚%�.�n޼��+rLH�� �Z�–-���=B��ep��5,X�жm;�ܹS�b*J�Hj ��L�cÇŽÅ?��tX����Qpss��)S�o�Q�HDDP Hz!.ΰ|��(S�#44-[������s�� t{�5��Ӡ�R�


    How can I show my picture ?
    Thx
    Got
    --
    Posted via http://www.ruby-forum.com/.
    -- Got, Dec 27, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jorge Rodriguez

    Scruffy Stacked Bar help

    Jorge Rodriguez, Jun 7, 2007, in forum: Ruby
    Replies:
    0
    Views:
    89
    Jorge Rodriguez
    Jun 7, 2007
  2. Ams Lone

    NameError - Scruffy and Gruff -

    Ams Lone, Aug 12, 2007, in forum: Ruby
    Replies:
    3
    Views:
    121
    Stefan Rusterholz
    Aug 12, 2007
  3. Damaris Fuentes

    Scruffy and bars

    Damaris Fuentes, Feb 11, 2008, in forum: Ruby
    Replies:
    0
    Views:
    93
    Damaris Fuentes
    Feb 11, 2008
  4. Damaris Fuentes

    Scruffy: is it possible the use of 3 axis?

    Damaris Fuentes, Feb 25, 2008, in forum: Ruby
    Replies:
    0
    Views:
    89
    Damaris Fuentes
    Feb 25, 2008
  5. Jack Richardson

    Scruffy - how to assign SVG Builder object

    Jack Richardson, Mar 18, 2008, in forum: Ruby
    Replies:
    0
    Views:
    104
    Jack Richardson
    Mar 18, 2008
Loading...

Share This Page