User can't copy graphs

153 views
Skip to first unread message

Pete

unread,
May 20, 2012, 1:30:13 PM5/20/12
to Google Visualization API
I've made some bar charts using the visualization API but because
they're not a single image, the browser doesn't allow the user to
right click and copy. Is there any way around this? My users would
find it really useful to have this functionality.

ChartMan

unread,
May 20, 2012, 3:45:02 PM5/20/12
to google-visua...@googlegroups.com
What type of copy do you like to enable ?
If you are using the google.visualization.ChartWrapper you can use the toJSON() method and expose a snippet the user can embed in 
another page. Does this work for you?

ChartMan


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.


Pete

unread,
May 26, 2012, 2:29:52 AM5/26/12
to Google Visualization API
I should have been more specific. My users would like to be able to
copy and paste an image of the chart into Word or other application. I
have tried JSON but that just gives me a string of an array describing
the chart.

rio

unread,
May 31, 2012, 9:11:44 PM5/31/12
to google-visua...@googlegroups.com
you will need to convert the SVG files into PNG

https://gist.github.com/1333906


You will then need to build a function that will build a function that will shrink and hide the div from its full size to 20X20 when requested by the user, and grow it again when the user generates another chart to image otherwise the div may cover the SVG and the user would loose all interactivity.

Alternately you can use the toImg function of that code. This wont display the chart as a PNG but allows you to download the image as a very very cryptic file name

rio

unread,
May 31, 2012, 9:18:21 PM5/31/12
to google-visua...@googlegroups.com
Alternately you can use the toImg function of that code. This wont display the chart as a PNG but allows you to download the image as a very very cryptic file name.

I seen a camera tool that can take screenshots of a very large image. Then it would take small portions of that image of  and roll it out along the bottom of the screen, each time you made a click requesting a new new image. This would be the ultimate way to display an interactive graph. Where you can request and display say 5 images and save them at your own leisure.

rio

unread,
Jun 7, 2012, 9:27:03 PM6/7/12
to google-visua...@googlegroups.com
 Great news I've been hard at work on improving this code.

I've made some nice progress to make it all user friendly.

A minimized chart is automatically enlarged when a toImg function is run

First of all the function toImg will run the exp() function and send a blank data/or its own id.
exp() will determine the element that made the request and expand the image when minimized

    if (obj != document.getElementById('b2')){
   
   
    document.getElementById('img_div').style.width="400px";
    document.getElementById('img_div').style.height=200px";
    document.getElementById('b2').innerHTML = 'hide popup';
    document.getElementById('b2').oldText = null;
    }
else
{
//regular code
}



//The image returned is set width and height (display) it does not clutter the screen. I found the best way of doing it is to do it when the image has been successfully created, rather than try and mess around with the image  data being sent out or returned.

You need to
1) give the image an ID.
2) Lookup that ID.
3) Apply the appropriate style height and width to the displayed image.

Pete

unread,
Jun 8, 2012, 11:31:05 AM6/8/12
to google-visua...@googlegroups.com
That sounds great thanks. I think I have what I need now.
Reply all
Reply to author
Forward
0 new messages