Thanks for the reply, Andrew.
I made various attempts to directly convert my graph to a PNG before
generating the PDF, to no avail. Your reminder that draw_graph uses
Gruff to create a PNG set me down a path where I ended up using Gruff
natively to create the PNG. So now I generate the data series once,
then call either Gruff or Ruport depending on my desired output
format:
g = Gruff::Line.new
g.data("Cost", axis_y)
g.labels = axis_x
send_data(g.to_blob, :disposition => 'inline', :type => 'image/
png', :filename => "GruffTest.png")
OR (in a separate class)
g = Graph(axis_x)
g.series axis_y, "Cost"
options.graph = g
...
draw_graph(options.graph, :title => "cost chart", :x => 100, :y =>
500, :width => width, :height => height)
I have a few things yet to be worked out, but the basic PNG/PDF
generators are working, so the rest should fall into place.
Regards,
Mark
On May 20, 6:32 pm, Andrew France <
andrew-li...@odaeus.co.uk> wrote:
> Welcome Mark,
>
> On 21/05/10 01:37, MarkB wrote:
>
> > Hello - I am new to Ruport and relatively new to Rails as well. Using
> > the excellent Ruport book I was able to get up and running with a PDF
> > chart of my data using the Ruport::Controller and
> > Ruport::Formatter::PDF classes.
>
> > I would like to render my chart as a PNG (JPG would be fine too)
> > directly in the browser and allow the user to download a PDF of the
> > same chart. The PDF is working, but I cannot figure out how to create
> > a PNG formatter. The book's example seems geared towards PDF output
> > using PDF::Writer.new, pdf.render, etc.
>
> I'm guessing you're doing something like:
http://ruportbook.com/payr_formatting_2.html#adding_a_graph
>
> I'm going to assume that you're using the Gruff graphing library, but
> others should be similar.
>
> > Is there a way to add a PNG formatter? I've looked at the SVG/PNG
> > example (
http://www.rubyreports.org/examples.html) using the
> > Ruport::Report class, but it lacks the formatting controls of the PDF
> > example and I don't know how I might extend it back to create a PDF.
>
> Looking at the Gruff support:
http://github.com/ruport/ruport-util/blob/master/lib/ruport/util/grap...