Skip to content

Commit

Permalink
[Discover] Fix Lens histogram not reacting to query/filter change
Browse files Browse the repository at this point in the history
  • Loading branch information
davismcphee committed Nov 2, 2022
1 parent 9084844 commit 5578336
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Side Public License, v 1.
*/

import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import type { AggregateQuery, Filter, Query } from '@kbn/es-query';
import type {
CountIndexPatternColumn,
DateHistogramIndexPatternColumn,
Expand All @@ -17,18 +17,18 @@ import type {
} from '@kbn/lens-plugin/public';

export const getLensAttributes = ({
data,
filters,
query,
dataView,
timeInterval,
breakdownField,
}: {
data: DataPublicPluginStart;
filters: Filter[];
query: Query | AggregateQuery;
dataView: DataView;
timeInterval: string | undefined;
breakdownField: DataViewField | undefined;
}) => {
const filters = data.query.filterManager.getFilters();
const query = data.query.queryString.getQuery();
const showBreakdown = breakdownField?.aggregatable;

let columnOrder = ['date_column', 'count_column'];
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/unified_histogram/public/chart/histogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ export function Histogram({
chart: { timeInterval, bucketInterval, data: chartData },
breakdown: { field: breakdownField } = {},
}: HistogramProps) {
const filters = data.query.filterManager.getFilters();
const query = data.query.queryString.getQuery();
const attributes = useMemo(
() => getLensAttributes({ data, dataView, timeInterval, breakdownField }),
[breakdownField, data, dataView, timeInterval]
() => getLensAttributes({ filters, query, dataView, timeInterval, breakdownField }),
[breakdownField, dataView, filters, query, timeInterval]
);

const { timefilter } = data.query.timefilter;
Expand Down

0 comments on commit 5578336

Please sign in to comment.