Find Questions…

Close ×
First time here? Check out the FAQ!

Embedding Google Charts within Confluence

Akeles asked this question · 1,353 karma ·

Anyone tried embedding Google Charts within Confluence?

I encountered a strange scenario where I embed a working code below within the html macro. It works in preview mode and the saved page, but will always throw error "undefined is not a function" during normal page view.

Thanks in advance.

<script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> // Load the Visualization API and the piechart package. google.load('visualization', '1', {'packages':['corechart']}); // Set a callback to run when the Google Visualization API is loaded. google.setOnLoadCallback(drawChart); // Callback that creates and populates a data table, // instantiates the pie chart, passes in the data and // draws it. function drawChart() { alert(google.visualization); // Create our data table. var data = new google.visualization.DataTable(); data.addColumn('string', 'Topping'); data.addColumn('number', 'Slices'); data.addRows([ ['Mushrooms', 3], ['Onions', 1], ['Olives', 1], ['Zucchini', 1], ['Pepperoni', 2] ]); // Instantiate and draw our chart, passing in some options. var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, {width: 400, height: 240}); } </script>
1371 views

2 Answers:

David Simpson · 16,745 karma ·

You might want to consider the gvCharts jQuery plugin if you want to reuse your code.

It'll take an HTML table and convert it into a Google Chart. It would be a bit more flexible if you want to roll this into a plugin at some stage. Here's a demo.

Akeles · 1,353 karma ·

Hi David, Thanks for the cool tip :)

Ellen Feaheny [AppFusions] · 5,839 karma ·

Yeh - this in on our roadmap for the AppFusions' Google Docs to Confluence (and JIRA) connector.

If anyone else wants this, do let us know at info@appfusions.com

It hasn't raised in priority that much - but we'll get to it..

Looking for something else?

Find Questions…

or Browse other questions tagged:

or Ask a Question