Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show/hide date histogram viz in Discover #17065

Closed
Closed
Show file tree
Hide file tree
Changes from 5 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
11 changes: 9 additions & 2 deletions src/core_plugins/kibana/public/discover/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ function discoverController(
columns: savedSearch.columns.length > 0 ? savedSearch.columns : config.get('defaultColumns').slice(),
index: $scope.indexPattern.id,
interval: 'auto',
filters: _.cloneDeep($scope.searchSource.getOwn('filter'))
filters: _.cloneDeep($scope.searchSource.getOwn('filter')),
showViz: true
};
}

Expand All @@ -292,6 +293,8 @@ function discoverController(
$state.save();
});

$scope.$watch('state.showViz', $state.save.bind($state));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we use a different variable name, like maybe isVizVisible or something? It is a little confusing here that state.showViz is a boolean while $scope.showViz is a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about isVizVis? 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isVizable!


$scope.opts = {
// number of records to fetch, then paginate through
sampleSize: config.get('discover:sampleSize'),
Expand Down Expand Up @@ -665,8 +668,12 @@ function discoverController(
$scope.minimumVisibleRows = $scope.hits;
};

$scope.showViz = () => $scope.state.showViz = true;
$scope.hideViz = () => $scope.state.showViz = false;

function setupVisualization() {
// If no timefield has been specified we don't create a histogram of messages
// If no timefield has been specified
// we don't create a histogram of messages
if (!$scope.opts.timefield) return;

const visStateAggs = [
Expand Down
58 changes: 36 additions & 22 deletions src/core_plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,43 @@ <h2>Searching</h2>
</span>
</button>

<section aria-label="Histogram of found documents" class="discover-timechart" ng-if="opts.timefield">
<section
ng-if="opts.timefield"
aria-label="Histogram of found documents"
class="discover-timechart"
>
<header>
<center class="small">
<span tooltip="To change the time, click the clock icon in the navigation bar">{{timeRange.from | moment}} - {{timeRange.to | moment}}</span>

&mdash;

<span class="results-interval form-inline">
<select
class="form-control"
ng-model="state.interval"
ng-options="interval.val as interval.display for interval in intervalOptions | filter: intervalEnabled"
ng-blur="toggleInterval()"
data-test-subj="discoverIntervalSelect"
>
</select>
<span ng-if="bucketInterval.scaled">
<icon-tip
content="getBucketIntervalToolTipText()"
position="'top'"
></icon-tip>
Scaled to {{ bucketInterval.description }}
<div ng-if="state.showViz">
<span tooltip="To change the time, click the clock icon in the navigation bar">{{timeRange.from | moment}} - {{timeRange.to | moment}}</span>

&mdash;

<span class="results-interval form-inline">
<select
class="form-control"
ng-model="state.interval"
ng-options="interval.val as interval.display for interval in intervalOptions | filter: intervalEnabled"
ng-blur="toggleInterval()"
data-test-subj="discoverIntervalSelect"
>
</select>
<span ng-if="bucketInterval.scaled">
<icon-tip
content="getBucketIntervalToolTipText()"
position="'top'"
></icon-tip>
Scaled to {{ bucketInterval.description }}
</span>

</span>
</span>
</div>
</center>

</header>

<visualization
ng-if="vis && rows.length != 0"
ng-if="state.showViz && vis && rows.length != 0"
vis="vis"
ui-state="uiState"
vis-data="visData"
Expand All @@ -139,6 +146,13 @@ <h2>Searching</h2>
style="height: 200px"
>
</visualization>

<div>
<center class="small">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

center is a deprecated html tag. I'm guessing you're using it because it's already used in the vis header. Since it's only used in those two places, I think it's worth fixing. It looks like they both only contain inline elements, so you should be able to just change it to a div and add text-align:center;

<a ng-if="!state.showViz" kbn-accessible-click ng-click="showViz()">Show visualization</a>
<a ng-if="state.showViz" kbn-accessible-click ng-click="hideViz()">Hide visualization</a>
</center>
</div>
</section>

<section class="discover-table" fixed-scroll aria-label="Documents">
Expand Down