4646 }
4747 </ style >
4848
49- < script >
50- var media = window . matchMedia ( '(min-width: 1024px)' ) ;
51-
52- media . addListener ( function ( ) {
53- document . getElementById ( 'resizing_chart' ) . drawChart ( ) ;
54- } ) ;
55- </ script >
56-
5749 < google-chart
5850 id ="resizing-chart "
5951 type ="column "
6355 rows ='[ ["Col1", 5.0],["Col2", 5.0],["Col3", 5.0] ] '>
6456 </ google-chart >
6557
58+ < script >
59+ var media = window . matchMedia ( '(min-width: 1024px)' ) ;
60+
61+ media . addListener ( function ( ) {
62+ document . getElementById ( 'resizing-chart' ) . drawChart ( ) ;
63+ } ) ;
64+ </ script >
65+
6666 < p > Here's a chart that changes data every 3 seconds:</ p >
6767
6868 < google-chart
131131 label . textContent = chart . selection [ 0 ] . row ;
132132
133133 chart . addEventListener ( 'google-chart-select' , function ( e ) {
134- var newSelection = e . detail . selection [ 0 ] ; // From the event details
134+ var newSelection = e . detail . chart . getSelection ( ) [ 0 ] ; // From the event details
135135 label . textContent = newSelection ? newSelection . row : 'None' ;
136136 } ) ;
137137
@@ -190,6 +190,14 @@ <h2>Chart gallery</h2>
190190 rows ='[["Jan", 31],["Feb", 28],["Mar", 31],["Apr", 30],["May", 31],["Jun", 30]] '>
191191 </ google-chart >
192192
193+ < p > And here is the material bar chart:</ p >
194+
195+ < google-chart
196+ type ="md-bar "
197+ options ='{"title": "Days in a month"} '
198+ cols ='[{"label": "Month", "type": "string"},{"label": "Days", "type": "number"}] '
199+ rows ='[["Jan", 31],["Feb", 28],["Mar", 31],["Apr", 30],["May", 31],["Jun", 30]] '> </ google-chart >
200+
193201 < p > Here's a bubble chart:</ p >
194202
195203 < google-chart
@@ -327,13 +335,13 @@ <h2>Chart gallery</h2>
327335 < script >
328336 ( function ( ) {
329337 var chart = document . getElementById ( 'timeline' ) ;
330- chart . pkg . then ( function ( viz ) {
331- chart . data = [
332- [ 'Name ', 'Start' , 'End' ] ,
333- [ 'Washington ', new Date ( 1789 , 3 , 30 ) , new Date ( 1797 , 2 , 4 ) ] ,
334- [ 'Adams ', new Date ( 1797 , 2 , 4 ) , new Date ( 1801 , 2 , 4 ) ] ,
335- [ 'Jefferson' , new Date ( 1801 , 2 , 4 ) , new Date ( 1809 , 2 , 4 ) ]
336- ] ;
338+ document . createElement ( 'google-chart-loader' ) . dataTable ( [
339+ [ 'Name' , 'Start' , 'End' ] ,
340+ [ 'Washington ', new Date ( 1789 , 3 , 30 ) , new Date ( 1797 , 2 , 4 ) ] ,
341+ [ 'Adams ', new Date ( 1797 , 2 , 4 ) , new Date ( 1801 , 2 , 4 ) ] ,
342+ [ 'Jefferson ', new Date ( 1801 , 2 , 4 ) , new Date ( 1809 , 2 , 4 ) ]
343+ ] ) . then ( function ( dataTable ) {
344+ chart . data = dataTable ;
337345 } ) ;
338346 } ( ) ) ;
339347 </ script >
@@ -432,13 +440,13 @@ <h2>Chart gallery</h2>
432440 < script >
433441 ( function ( ) {
434442 var chart = document . getElementById ( 'source-datatable' ) ;
435- chart . pkg . then ( function ( viz ) {
436- chart . data = viz . arrayToDataTable ( [
437- [ 'Label ', 'Value' ] ,
438- [ 'Memory ', 10 ] ,
439- [ 'CPU ', 12 ] ,
440- [ 'Network' , 14 ]
441- ] ) ;
443+ document . createElement ( 'google-chart-loader' ) . dataTable ( [
444+ [ 'Label' , 'Value' ] ,
445+ [ 'Memory ', 10 ] ,
446+ [ 'CPU ', 12 ] ,
447+ [ 'Network ', 14 ]
448+ ] ) . then ( function ( dataTable ) {
449+ chart . data = dataTable ;
442450 } ) ;
443451 } ( ) ) ;
444452 </ script >
@@ -455,40 +463,39 @@ <h2>Chart gallery</h2>
455463 < script >
456464 ( function ( ) {
457465 var chart = document . getElementById ( 'source-dataview' ) ;
458- chart . pkg . then ( function ( viz ) {
459- var dataTable = viz . arrayToDataTable ( [
460- [ 'Label' , 'Value' ] ,
461- [ 'Memory' , 10 ] ,
462- [ 'CPU' , 12 ] ,
463- [ 'Network' , 14 ]
464- ] ) ;
465- chart . view = new google . visualization . DataView ( dataTable ) ;
466- var setRandomRow = function ( ) {
467- var rowCount = dataTable . getNumberOfRows ( ) ;
468- var row = Math . floor ( Math . random ( ) * rowCount ) ;
469- var row2 = ( row + 1 ) % rowCount ;
470- chart . view . setRows ( [ row , row2 ] ) ;
471- chart . drawChart ( ) ;
472- } ;
473- setInterval ( setRandomRow , 3000 ) ;
466+ var loader = document . createElement ( 'google-chart-loader' ) ;
467+ loader . dataTable ( [
468+ [ 'Label' , 'Value' ] ,
469+ [ 'Memory' , 10 ] ,
470+ [ 'CPU' , 12 ] ,
471+ [ 'Network' , 14 ]
472+ ] ) . then ( function ( dataTable ) {
473+ loader . dataView ( dataTable ) . then ( function ( dataView ) {
474+ chart . view = dataView ;
475+ var setRandomRow = function ( ) {
476+ var rowCount = dataTable . getNumberOfRows ( ) ;
477+ var row = Math . floor ( Math . random ( ) * rowCount ) ;
478+ var row2 = ( row + 1 ) % rowCount ;
479+ chart . view . setRows ( [ row , row2 ] ) ;
480+ chart . drawChart ( ) ;
481+ } ;
482+ setInterval ( setRandomRow , 3000 ) ;
483+ } ) ;
474484 } ) ;
475485 } ( ) ) ;
476486 </ script >
477487
478488 < p > Here's an image of the line chart:</ p >
479489
480- < div id =' line-chart-img-container ' > </ div >
490+ < img id =" line-chart-img " >
481491
482492 < script >
483493 ( function ( ) {
484494 var chart = document . getElementById ( 'line-chart' ) ;
485- var imgContainer = document . getElementById ( 'line-chart-img-container ' ) ;
495+ var img = document . getElementById ( 'line-chart-img' ) ;
486496
487- chart . addEventListener ( 'google-chart-render' , function ( ) {
488- var img = document . createElement ( 'img' ) ;
489- img . src = chart . getImageURI ( ) ;
490- imgContainer . innerHTML = '' ;
491- imgContainer . appendChild ( img ) ;
497+ chart . addEventListener ( 'google-chart-ready' , function ( ) {
498+ img . src = chart . imageURI ;
492499 } ) ;
493500 } ( ) ) ;
494501 </ script >
0 commit comments