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

fix(heatmap): filter out tooltip picked shapes in x-axis area #1351

Merged
merged 6 commits into from
Sep 3, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ import { GlobalChartState } from '../../../../state/chart_state';
import { createCustomCachedSelector } from '../../../../state/create_selector';
import { Cell, TextBox } from '../../layout/types/viewmodel_types';
import { geometries } from './geometries';
import { getGridHeightParamsSelector } from './get_grid_full_height';

function getCurrentPointerPosition(state: GlobalChartState) {
return state.interactions.pointer.current.position;
}

/** @internal */
export const getPickedShapes = createCustomCachedSelector(
[geometries, getCurrentPointerPosition],
(geoms, pointerPosition): Cell[] | TextBox => {
[geometries, getCurrentPointerPosition, getGridHeightParamsSelector],
(geoms, pointerPosition, gridParams): Cell[] | TextBox => {
const picker = geoms.pickQuads;
const { x, y } = pointerPosition;
return picker(x, y);
const pickedData = picker(x, y);
return Array.isArray(pickedData)
? pickedData.filter(({ y }) => y < gridParams.gridCellHeight * gridParams.pageSize)
: pickedData;
},
);
4 changes: 3 additions & 1 deletion storybook/stories/heatmap/2_categorical.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { action } from '@storybook/addon-actions';
import { boolean } from '@storybook/addon-knobs';
import React from 'react';

import { Chart, Heatmap, Settings } from '@elastic/charts';
Expand All @@ -15,7 +16,8 @@ import { BABYNAME_DATA } from '@elastic/charts/src/utils/data_samples/babynames'
import { useBaseTheme } from '../../use_base_theme';

export const Example = () => {
const data = BABYNAME_DATA.filter(([year]) => year > 1950 && year < 1960);
const filterData = boolean('filter BABYNAME_DATA', false);
const data = filterData ? BABYNAME_DATA : BABYNAME_DATA.filter(([year]) => year > 1950 && year < 1960);
Copy link
Member

Choose a reason for hiding this comment

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

Isn't that the inverse?
If I check the filter knob to enable the filter I should see only a partial set.
If the filter check is off, then I should see all the data available.
Two code change:

  • reverse the ternary operation and change the default value of the checkbox to true
  • rename the filter to: filter dataset. The BABYNAME_DATA is something we don't want to show to the user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yikes good catch thanks 38147b4


return (
<Chart>
Expand Down