mirror of https://github.com/apache/superset.git
Make brush send events (#5663)
* Make brush send events * Make sure object is date * Send event only on brushend
This commit is contained in:
parent
6e8c7f7b20
commit
2a8cd43881
|
@ -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'),
|
||||
|
|
|
@ -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'],
|
||||
],
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue