Skip to main content
deleted 27 characters in body
Source Link

I'm wondering if you shouldn't just rethinkInstead of using Google's google.setOnLoadCallback(drawChart); event in your solution. In my opinionjavascript, you're adding an unnecessary post back to the pagetry using _spBodyOnLoadFunctionNames.push("drawChart");. Instead of having

My theory is that by the server re-writetime Google's API has loaded, your JavaScriptpage's DOM has not been fully built, include both charts on the page and use CSSso there is no "chart_div" to layer them on top of each otheraccess. Hide the second chart

Sidenote: I would recommend using CSS, and then use a simple JavaScript function to switch between the two charts when they click on the radio buttonsStringBuilder class instead of all of that concatenation. The user will experience a smaller delay between switching It has nothing to do with your problem, and it won't require loadingbut doing an entire SharePoint page over again, whichAppendLine("...") is already a slow processeasier than putting \n everywhere. Feel free to ignore this if you want.

I'm wondering if you shouldn't just rethink your solution. In my opinion, you're adding an unnecessary post back to the page. Instead of having the server re-write your JavaScript, include both charts on the page and use CSS to layer them on top of each other. Hide the second chart using CSS, and then use a simple JavaScript function to switch between the two charts when they click on the radio buttons. The user will experience a smaller delay between switching, and it won't require loading an entire SharePoint page over again, which is already a slow process.

Instead of using Google's google.setOnLoadCallback(drawChart); event in your javascript, try using _spBodyOnLoadFunctionNames.push("drawChart");.

My theory is that by the time Google's API has loaded, your page's DOM has not been fully built, and so there is no "chart_div" to access.

Sidenote: I would recommend using the StringBuilder class instead of all of that concatenation. It has nothing to do with your problem, but doing an AppendLine("...") is easier than putting \n everywhere. Feel free to ignore this if you want.

Source Link

I'm wondering if you shouldn't just rethink your solution. In my opinion, you're adding an unnecessary post back to the page. Instead of having the server re-write your JavaScript, include both charts on the page and use CSS to layer them on top of each other. Hide the second chart using CSS, and then use a simple JavaScript function to switch between the two charts when they click on the radio buttons. The user will experience a smaller delay between switching, and it won't require loading an entire SharePoint page over again, which is already a slow process.