If you think you might reuse the charting code for other things, make it a class, put it in lib
and set it up so you can do something like this in your controller:
@chart = MyChart.new(:data => @my_object.data_method, :title => 'Foo Chart', ....)
send_data @chart.to_svg, ...
..
This way you can extend it with other options, add .to_png
, etc without mucking up your model.