Search code examples
ruby-on-railstwitterhighchartsscreenshot

Rails: Screenshot a div then share via twitter?


I have a highcharts chart in a div. I want to make it easy for users to tweet it out. How could I do this? I was thinking of a screenshot gem then integrate the twitter API. Is this possible? Or is there a better way? Thank you.


Solution

  • You could render the image server side, and then share it out via some client side JS tools such as Share This.

    Render HighCharts on the server: http://www.highcharts.com/docs/export-module/render-charts-serverside

    Once you have the image, use it for sharing by including it in your HTML.

    Share This docs: http://support.sharethis.com/customer/portal/articles/475079-share-properties-and-sharing-custom-information#sthash.QCmTvDs6.dpbs

    This may be a slightly different approach than what you were looking for, but it works.