Re: Chart is missing when column add & remove.

49 views
Skip to first unread message

asgallant

unread,
Dec 4, 2012, 12:28:25 PM12/4/12
to google-visua...@googlegroups.com
If you post your code or a link to the page, I'll take a look.

On Tuesday, December 4, 2012 5:30:36 AM UTC-5, nikku wrote:
Hi Guys,

i am using transition animations and the modification add/remove column. but when i use add/remove column my chart donot show any line or column. its happen with IE7, ie8, IE9


sumit

unread,
Dec 5, 2012, 4:41:58 AM12/5/12
to google-visua...@googlegroups.com
Here is the link http://www.marketbaro.com/others/reality_check

Thanks,
nikku

asgallant

unread,
Dec 5, 2012, 4:09:49 PM12/5/12
to google-visua...@googlegroups.com
Ok, sorry this took so long, but it took me a while to decipher that code.  I believe the primary problem here is that you are trying to create dates from the returned data by using strings:

new Date(rec_set[j]['h_axis'])

where rec_set[j]['h_axis'] is something in the format "2012, 10, 6".  This is functional in Firefox and Chrome, but IE does not allow it.  Split your date string into it's component parts, parse them as integers (subtracting 1 for the month, for Date compatibility), and pass them to the Date constructor, like this:

for (var 0rec_set.lengthj++{
    var dateArr rec_set[j]['h_axis'].split(', ');
    var year parseInt(dateArr[0]);
    var month parseInt(dateArr[1]1;
    var day parseInt(dateArr[2]);
    data.addRow([new Date(yearmonthday)rec_set[j]['base_quotes']rec_set[j]['target_24h']rec_set[j]['target_1w']rec_set[j]['target_1m']]);
}

It's also worth noting that this:

for (var 0data.getNumberOfColumns()j++{
    for (var 0data.getNumberOfRows()i++{
        data.removeRow(i);
    }
}

is unnecessarily complicated, and probably doesn't do what you want anyway.  For each column, you are getting rid of half of the rows of data, because every time you remove a row, all of the row indices above that one shift down 1, so after 1 pass, you end up with a data table containing all of the odd numbered rows (remove row 0, row 1 shifts down to 0, remove the new row 1 (old row 2), row 2 (old row 3) shifts down to 1, etc).  If your goal here is to empty the table, then you can do that very simply with the #removeRows method:

data.removeRows(0data.getNumberOfRows() 1);

While I'm at it, why do you requery the data every time you change the columns?  It would be much more efficient to transfer the data once, and use a DataView to show or hide the columns.  You would only need to requery if the whole data set needs to be changed or updated.

Reading over this, it might seem like I'm being harsh - if it comes across that way, I apologize, that's not my intention.

sumit

unread,
Dec 5, 2012, 11:18:49 PM12/5/12
to google-visua...@googlegroups.com
Hi Asgallent,

thanks for your reply let me go through this.

asgallant

unread,
Dec 6, 2012, 1:46:27 AM12/6/12
to google-visua...@googlegroups.com
You're welcome.
Reply all
Reply to author
Forward
0 new messages