Refresh google table chart

40 views
Skip to first unread message

TheInnovator

unread,
May 28, 2014, 2:42:04 PM5/28/14
to google-visua...@googlegroups.com
I have created a table using google charts.
The problem that I'm having is that the table does not refresh.

Enter in "10/2013" for this month and "9/2013" for last month and click submit.
Now enter "8/2013" for this month and "7/2013" for last month and click submit.
As you will notice, on the second set of entries, the table did not refresh.

http://isaac.issharepoint.com/Web%20Part%20Page/508Dashboard.aspx

Is there a table method that permits the table to refresh back to 0?

Thanks

Andrew Gallant

unread,
May 28, 2014, 3:56:55 PM5/28/14
to google-visua...@googlegroups.com
You need to zero-out the values in anArray and lanArray every time you return from your AJAX, like this:

$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "508 Dashboard Data",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title'></FieldRef><FieldRef Name='Year'></FieldRef><FieldRef Name='FileType'></FieldRef><FieldRef Name='TotalFailed'></FieldRef><FieldRef Name='TotalPassed'></FieldRef><FieldRef Name='TotalScanned'></FieldRef><FieldRef Name='score'></FieldRef></ViewFields>",
    CAMLQuery: qry(monthWord, yearDte), //Function to call query
    completefunc: function (xData, Status) {
       
for (var x=0; x < anArray.length; x++)
        {

            anArray[x].totalPages = 0;
            anArray[x].totalPassed = 0;
            anArray[x].totalFailed = 0;
            anArray[x].score = null;

        }
        $(xData.responseXML).SPFilterNode("z:row").each(function() {
            for (var x=0; x < anArray.length; x++)
            {
                var fileType = getDte($(this).attr("ows_FileType"));
                if (fileType == anArray[x].Title)
                {
                    anArray[x].totalPages = Number($(this).attr("ows_TotalScanned"));
                    anArray[x].totalPassed = Number($(this).attr("ows_TotalPassed"));
                    anArray[x].totalFailed = Number($(this).attr("ows_TotalFailed"));
                    anArray[x].score = Number($(this).attr("ows_TotalPassed"))/Number($(this).attr("ows_TotalScanned"));
                    x++;
                }
            }
        });
    }
});

Isaac Sogunro

unread,
May 28, 2014, 6:24:30 PM5/28/14
to google-visua...@googlegroups.com
That worked if the next entry has data.

Try this,
Enter "11/2013" for "This Month" and "10/2013" for "Last Month" and click Submit.
Enter "11/2013" for "This Month" and "5/2013" for "Last Month" and click Submit.

Because there is no data for "5/2013", it never enters the .each() loop.


Any ideas?
Everything i've tried doesn't work.

Thanks!





--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/Qs7TF3fuxo8/unsubscribe.
To unsubscribe from this group and all its topics, 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.



--
-Isaac-

http://twitter.com/#!/feedy0urmind
You are today where your thoughts have brought you; you will be tomorrow where your thoughts take you.
- James Allen

Andrew Gallant

unread,
May 28, 2014, 9:13:54 PM5/28/14
to google-visua...@googlegroups.com
It shouldn't matter whether it enters the "each" loop or not.  You're zeroing out all the data with this section:


for (var x=0; x < anArray.length; x++)
{

    anArray[x].totalPages = 0;
    anArray[x].totalPassed = 0;
    anArray[x].totalFailed = 0;
    anArray[x].score = null;

}


Looking over the source, you are setting and testing the state of a flag to determine whether or not you zero-out the data - what is the purpose of this?
To unsubscribe from this group and all its topics, 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.

Isaac Sogunro

unread,
May 29, 2014, 9:56:40 AM5/29/14
to google-visua...@googlegroups.com
I see what I did wrong.
I put the for loop in the wrong spot.
It works now!

Thanks a lot.


On Wed, May 28, 2014 at 3:56 PM, Andrew Gallant <asgall...@gmail.com> wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/Qs7TF3fuxo8/unsubscribe.
To unsubscribe from this group and all its topics, 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.
Reply all
Reply to author
Forward
0 new messages