Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions google-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ Polymer({
google.visualization.events.addListener(chartWrapper, 'ready', () => {
this._setDrawn(true);
});
google.visualization.events.addListener(chartWrapper, 'select', () => {
this.selection = chartWrapper.getChart().getSelection();
});
this._propagateEvents(DEFAULT_EVENTS, chartWrapper);
});
},
Expand Down
21 changes: 21 additions & 0 deletions test/basic-tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@
return chart.$$('rect[stroke="#ffffff"]');
}, done);
});
test('updates selection', function(done) {
chart.data = [
['Data', 'Value'],
['Something 1', 1],
['Something 2', 2],
['Something 3', 3],
];
chart.addEventListener('google-chart-select', () => {
assert.sameDeepMembers(chart.selection, [ {row: 2, column: 1} ]);
done();
}, {once: true});
chart.selection = [ {row: 0, column: 1} ];
chart.addEventListener('google-chart-ready', () => {
// Look for something that can be clicked. Find rectangles for legend
// and each bar.
const rects = chart.$$('#chartdiv')
.querySelectorAll('rect[fill="#3366cc"]');
// Click on the last bar ('Something 3').
rects[3].dispatchEvent(new MouseEvent('click', {bubbles: true}));
}, {once: true});
});
test('default options are null', function() {
assert.equal(chart.options, null);
});
Expand Down