Skip to content

Commit

Permalink
Make brush send events (apache#5663)
Browse files Browse the repository at this point in the history
* Make brush send events

* Make sure object is date

* Send event only on brushend
  • Loading branch information
betodealmeida authored and mistercrunch committed Aug 22, 2018
1 parent c680d67 commit da89c16
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions superset/assets/src/explore/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,14 @@ export const controls = {
description: t('Whether to display the legend (toggles)'),
},

send_time_range: {
type: 'CheckboxControl',
label: t('Propagate'),
renderTrigger: true,
default: false,
description: t('Send range filter events to other charts'),
},

show_labels: {
type: 'CheckboxControl',
label: t('Show Labels'),
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/src/explore/visTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const visTypes = {
expanded: true,
controlSetRows: [
['color_scheme'],
['show_brush', 'show_legend'],
['show_brush', 'send_time_range', 'show_legend'],
['rich_tooltip', 'show_markers'],
['line_interpolation'],
],
Expand Down
11 changes: 11 additions & 0 deletions superset/assets/src/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@ export default function nvd3Vis(slice, payload) {
throw new Error('Unrecognized visualization for nvd3' + vizType);
}

if (isTruthy(fd.show_brush) && isTruthy(fd.send_time_range)) {
chart.focus.dispatch.on('brush', (event) => {
const extent = event.extent;
if (extent.some(d => d.toISOString === undefined)) {
return;
}
const timeRange = extent.map(d => d.toISOString().slice(0, -1)).join(' : ');
event.brush.on('brushend', () => slice.addFilter('__time_range', timeRange, false, true));
});
}

if (chart.xAxis && chart.xAxis.staggerLabels) {
chart.xAxis.staggerLabels(staggerLabels);
}
Expand Down

0 comments on commit da89c16

Please sign in to comment.