Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank Page #46

Open
Bartkula opened this issue Feb 22, 2015 · 4 comments
Open

Blank Page #46

Bartkula opened this issue Feb 22, 2015 · 4 comments

Comments

@Bartkula
Copy link

i have grails 2.4.4 and i use the plugin: compile ":google-visualization:1.0.1", it shows no error, and i set up both examples in github : Rendering a visualization in a GSP and Rendering a visualization in a AJAX response but in both i get a blank page, in the ajax example, the button is showed but when i press nothing happens not even error is shown in the IDE (intellij). Unfortunatelly there is not much doc. about how to implement this api plugin. Thanks in advance

@aruizca
Copy link
Collaborator

aruizca commented Feb 22, 2015

Please share your code and then I might be able to help you. Please let us know what part of the doco is not clear

@Bartkula
Copy link
Author

i was able to make the first example work, , but the second just show the button and when i press it nothing happens:
here is my controller

class ShowchartController {
   def render() {
        def myDailyActivitiesColumns = [['string', 'Task'], ['number', 'Hours per Day']]
        def myDailyActivitiesData = [['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7]]
        render template: "chart", model: ["myDailyActivitiesColumns": myDailyActivitiesColumns, "myDailyActivitiesData": myDailyActivitiesData]        
    }    
}

it's the same that in the example, then my view

<!DOCTYPE html>
<html>
<head>
    <title>Charts</title>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
</head>
<body>
<input type="button" value="Render Pie Chart"
       onclick="${remoteFunction(controller:'showchart',action:'render',update:'chart')}">
<br>
<div id="chart"></div>
</body>
</html>

and then the template _chart:

<div id="piechart"></div>
<gvisualization:pieCoreChart dynamicLoading="${true}" elementId="piechart" title="My Daily Activities" width="${450}" height="${300}" columns="${myDailyActivitiesColumns}" data="${myDailyActivitiesData}"/> 

thanks in advance for your help, regards !

@aruizca
Copy link
Collaborator

aruizca commented Feb 25, 2015

It'd help if you provide a GitHub repo with the example

@groovyGuy
Copy link

I am getting (what sounds like) the same issue by the description he gives. When he says blank page, I am guessing both he and I are facing the issue described here http://stackoverflow.com/questions/9519673/why-does-google-load-cause-my-page-to-go-blank

The issue is that Google adds the script to the page using document.write. I was rendering a template upon button click (obviously after load of page). When I click the button, the whole page goes white. Showing the source code just has the scripts on the page. Here is my code (please forgive the lack of formatting. I am new to github):

on Main.gsp head section:

<head>
...other scripts
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <gvisualization:apiImport/> 
</head>

This loads fine in main.gsp upon lage load:

<div class="body">
    <%
        def myDailyActivitiesColumns = [['string', 'Task'], ['number', 'Hours per Day']]
        def myDailyActivitiesData = [['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7]]
    %>
    <gvisualization:barCoreChart elementId="piechart" title="My Daily Activities" width="${450}" height="${300}"
                                 columns="${myDailyActivitiesColumns}" data="${myDailyActivitiesData}"/>
    <div id="piechart"></div>
</div>

In my template (rendered upon button click):

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta name="layout" content="main"/>
<title>KPI Charts</title>
</head>
<body>
<div class="body">
    <%
        def myDailyActivitiesColumns = [['string', 'Task'], ['number', 'Hours per Day']]
        def myDailyActivitiesData = [['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7]]
    %>
    <gvisualization:barCoreChart elementId="piechart" title="My Daily Activities" width="${450}" height="${300}"
                                 columns="${myDailyActivitiesColumns}" data="${myDailyActivitiesData}"/>
    <div id="piechart"></div>
</div>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants