How to get the new ImageURI after changing the chart with chartEditor to print the new image (png)

245 views
Skip to first unread message

Physique Versaillles Crtt

unread,
Jun 26, 2015, 6:09:17 AM6/26/15
to google-visua...@googlegroups.com
Hello,
    I use the chartEditor to change the chart, for exemple, from the linechart to piechart. At first, I add the 'ready' listener for chartWrapper. In the function, I use the fonction getImageURI() to get the ImageURI. 
    Then, I use the chartEditor to change the chart. I add the listener 'OK' for chartEditor. In the fonction 'OK', I couldn't get ImageURI().

    If I use the fonction below

    chartEditor.getChartWrapper().getChart() 

    I get 'null'. How can I get the new ImageURI.

I would like this new ImageURI to print the new image (png) from the new chart edited.

Thank you.

Best regards

Sergey Grabkovsky

unread,
Jun 26, 2015, 10:25:49 AM6/26/15
to google-visua...@googlegroups.com
Hi, did you try listening to the OK event, then attaching a listener for the ready event? Could you make a jsfiddle showing the issue?

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Physique Versaillles Crtt

unread,
Jul 2, 2015, 6:13:34 AM7/2/15
to google-visua...@googlegroups.com
I've already used OK event and ready event. This is the example of jsfiddle what I made.


When I click 'Click Me', the diagram is opened in a new tab. When I click 'Edit me', then I click 'Clike Me', I want that the new diagram is opened. But now, the old diagram is always opened.

I tried to use the code below in the function 'redrawChart()' to get the adresse of the new diagram: 

var imgMachineURI = chartEditor.getChartWrapper().getChart().getImageURI();

But chartEditor.getChartWrapper().getChart() return 'null'. (No matter I put the code before or after 'chartEditor.getChartWrapper().draw(document.getElementById('vis_div')); ')

So I don't know why. Do you have some ideas?

Thanks

Le vendredi 26 juin 2015 16:25:49 UTC+2, Sergey a écrit :
Hi, did you try listening to the OK event, then attaching a listener for the ready event? Could you make a jsfiddle showing the issue?

On Fri, Jun 26, 2015 at 6:09 AM Physique Versaillles Crtt <physiq...@gmail.com> wrote:
Hello,
    I use the chartEditor to change the chart, for exemple, from the linechart to piechart. At first, I add the 'ready' listener for chartWrapper. In the function, I use the fonction getImageURI() to get the ImageURI. 
    Then, I use the chartEditor to change the chart. I add the listener 'OK' for chartEditor. In the fonction 'OK', I couldn't get ImageURI().

    If I use the fonction below

    chartEditor.getChartWrapper().getChart() 

    I get 'null'. How can I get the new ImageURI.

I would like this new ImageURI to print the new image (png) from the new chart edited.

Thank you.

Best regards

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.

Daniel LaLiberte

unread,
Jul 2, 2015, 11:19:16 AM7/2/15
to google-visua...@googlegroups.com
Hi Physique,

After editing the chart, a new chart wrapper is constructed and returned with getChartWrapper().  You need to use that one thereafter rather than your original wrapper.  I'm not sure whether you'll need to attach new event handlers to that new chart wrapper, or if the chart editor automatically rebinds the same handlers, but I suspect you will.  We should update the documentation to clarify all this.

On Thu, Jul 2, 2015 at 6:13 AM, Physique Versaillles Crtt <physiq...@gmail.com> wrote:
I've already used OK event and ready event. This is the example of jsfiddle what I made.


When I click 'Click Me', the diagram is opened in a new tab. When I click 'Edit me', then I click 'Clike Me', I want that the new diagram is opened. But now, the old diagram is always opened.

I tried to use the code below in the function 'redrawChart()' to get the adresse of the new diagram: 

var imgMachineURI = chartEditor.getChartWrapper().getChart().getImageURI();

But chartEditor.getChartWrapper().getChart() return 'null'. (No matter I put the code before or after 'chartEditor.getChartWrapper().draw(document.getElementById('vis_div')); ')

So I don't know why. Do you have some ideas?

Thanks

Le vendredi 26 juin 2015 16:25:49 UTC+2, Sergey a écrit :
Hi, did you try listening to the OK event, then attaching a listener for the ready event? Could you make a jsfiddle showing the issue?

On Fri, Jun 26, 2015 at 6:09 AM Physique Versaillles Crtt <physiq...@gmail.com> wrote:
Hello,
    I use the chartEditor to change the chart, for exemple, from the linechart to piechart. At first, I add the 'ready' listener for chartWrapper. In the function, I use the fonction getImageURI() to get the ImageURI. 
    Then, I use the chartEditor to change the chart. I add the listener 'OK' for chartEditor. In the fonction 'OK', I couldn't get ImageURI().

    If I use the fonction below

    chartEditor.getChartWrapper().getChart() 

    I get 'null'. How can I get the new ImageURI.

I would like this new ImageURI to print the new image (png) from the new chart edited.

Thank you.

Best regards

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

Physique Versaillles Crtt

unread,
Jul 3, 2015, 3:45:25 AM7/3/15
to google-visua...@googlegroups.com
I have tried to use the new wrapper with the function getChartWrapper(). I've also tried to attach the 'ready' event handlder to the new wrapper in the function 'readyRedraw()' (the 'OK' event handler of chartEditor).
But only the old 'ready' event handler  executes once . Even if I change the diagram after, the new 'ready' event handler does not executed any more.

I change the code for the test : https://jsfiddle.net/IvZhc/f0ptawpw/4/

Thank you for your response.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.



--
dlali...@Google.com   5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA

Daniel LaLiberte

unread,
Jul 4, 2015, 2:05:52 PM7/4/15
to google-visua...@googlegroups.com
When you open the editor again, you need to use the new wrapper.

When you create the image, you need to not replace the outerHTML since that is where your id is, so it would never be found again.

It appears that calling getChartWrapper() creates a new chart wrapper each time.  Not sure yet, but if you avoid calling getChartWrapper more than once, it seems to work, with the other changes.  See https://jsfiddle.net/f0ptawpw/5/

To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.



--
dlali...@Google.com   5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

Physique Versaillles Crtt

unread,
Jul 6, 2015, 3:36:23 AM7/6/15
to google-visua...@googlegroups.com
Thank you Daniel! It works!
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.



--
dlali...@Google.com   5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages