Skip to content

Commit

Permalink
added support for getImageURI()
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Blechschmidt committed Nov 5, 2015
1 parent 2ac6dc3 commit 158c81f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ <h2>Chart gallery</h2>
<p>Here's a line chart:</p>

<google-chart
id='line_chart'
type='line'
options='{"title": "Days in a month"}'
cols='[{"label": "Month", "type": "string"},{"label": "Days", "type": "number"}]'
Expand Down Expand Up @@ -388,6 +389,22 @@ <h2>Chart gallery</h2>
["Congo", "Africa", 10],
["Zaire", "Africa", 8]]'>
</google-chart>

<p>Here's an image of the line chart:</p>

<div id='line_chart_div'></div>

<script>
document.addEventListener('WebComponentsReady', function() {
var chart_div = document.querySelector('#line_chart_div');
var chart = document.querySelector('#line_chart');

chart.addEventListener('google-chart-render', function() {
chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">';
});

});
</script>

</body>
</html>
12 changes: 12 additions & 0 deletions google-chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,18 @@
return null;
},

/**
* Returns the chart serialized as an image URI.
*
* Call this after the chart is drawn (google-chart-render event).
*
* @method getImageURI
* @return {string} Returns image URI.
*/
getImageURI: function() {
return this._chartObject.getImageURI();
},

_loadChartTypes: function() {
this._chartTypes = {
'area': google.visualization.AreaChart,
Expand Down

0 comments on commit 158c81f

Please sign in to comment.