File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -364,6 +364,9 @@ Polymer({
364364 google . visualization . events . addListener ( chartWrapper , 'ready' , ( ) => {
365365 this . _setDrawn ( true ) ;
366366 } ) ;
367+ google . visualization . events . addListener ( chartWrapper , 'select' , ( ) => {
368+ this . selection = chartWrapper . getChart ( ) . getSelection ( ) ;
369+ } ) ;
367370 this . _propagateEvents ( DEFAULT_EVENTS , chartWrapper ) ;
368371 } ) ;
369372 } ,
Original file line number Diff line number Diff line change 7979 return chart . $$ ( 'rect[stroke="#ffffff"]' ) ;
8080 } , done ) ;
8181 } ) ;
82+ test ( 'updates selection' , function ( done ) {
83+ chart . data = [
84+ [ 'Data' , 'Value' ] ,
85+ [ 'Something 1' , 1 ] ,
86+ [ 'Something 2' , 2 ] ,
87+ [ 'Something 3' , 3 ] ,
88+ ] ;
89+ chart . addEventListener ( 'google-chart-select' , ( ) => {
90+ assert . sameDeepMembers ( chart . selection , [ { row : 2 , column : 1 } ] ) ;
91+ done ( ) ;
92+ } , { once : true } ) ;
93+ chart . selection = [ { row : 0 , column : 1 } ] ;
94+ chart . addEventListener ( 'google-chart-ready' , ( ) => {
95+ // Look for something that can be clicked. Find rectangles for legend
96+ // and each bar.
97+ const rects = chart . $$ ( '#chartdiv' )
98+ . querySelectorAll ( 'rect[fill="#3366cc"]' ) ;
99+ // Click on the last bar ('Something 3').
100+ rects [ 3 ] . dispatchEvent ( new MouseEvent ( 'click' , { bubbles : true } ) ) ;
101+ } , { once : true } ) ;
102+ } ) ;
82103 test ( 'default options are null' , function ( ) {
83104 assert . equal ( chart . options , null ) ;
84105 } ) ;
You can’t perform that action at this time.
0 commit comments