Show "Range Filter" by default (#4604)

* Show Range Filter by default

* Auto show brush

* Backwards compat

* Small fix
This commit is contained in:
Beto Dealmeida 2018-03-14 16:38:47 -07:00 committed by Maxime Beauchemin
parent 3371c8bd5c
commit 86a03d1dc8
2 changed files with 16 additions and 5 deletions

View File

@ -1261,10 +1261,16 @@ export const controls = {
}, },
show_brush: { show_brush: {
type: 'CheckboxControl', type: 'SelectControl',
label: t('Range Filter'), label: t('Show Range Filter'),
renderTrigger: true, renderTrigger: true,
default: false, clearable: false,
default: 'auto',
choices: [
['yes', 'Yes'],
['no', 'No'],
['auto', 'Auto'],
],
description: t('Whether to display the time range interactive selector'), description: t('Whether to display the time range interactive selector'),
}, },

View File

@ -22,6 +22,7 @@ const minBarWidth = 15;
// Limit on how large axes margins can grow as the chart window is resized // Limit on how large axes margins can grow as the chart window is resized
const maxMarginPad = 30; const maxMarginPad = 30;
const animationTime = 1000; const animationTime = 1000;
const minHeightForBrush = 480;
const BREAKPOINTS = { const BREAKPOINTS = {
small: 340, small: 340,
@ -158,9 +159,14 @@ function nvd3Vis(slice, payload) {
if (svg.empty()) { if (svg.empty()) {
svg = d3.select(slice.selector).append('svg'); svg = d3.select(slice.selector).append('svg');
} }
let height = slice.height();
switch (vizType) { switch (vizType) {
case 'line': case 'line':
if (fd.show_brush) { if (
fd.show_brush === true ||
fd.show_brush === 'yes' ||
(fd.show_brush === 'auto' && height >= minHeightForBrush)
) {
chart = nv.models.lineWithFocusChart(); chart = nv.models.lineWithFocusChart();
chart.focus.xScale(d3.time.scale.utc()); chart.focus.xScale(d3.time.scale.utc());
chart.x2Axis.staggerLabels(false); chart.x2Axis.staggerLabels(false);
@ -332,7 +338,6 @@ function nvd3Vis(slice, payload) {
} }
} }
let height = slice.height();
if (vizType === 'bullet') { if (vizType === 'bullet') {
height = Math.min(height, 50); height = Math.min(height, 50);
} }